当前位置:网站首页>js \n\r 换行失败 :【white-space: pre-line;】${} Template Literals
js \n\r 换行失败 :【white-space: pre-line;】${} Template Literals
2022-08-03 13:06:00 【刀枪不入de王二花】
问题:
js 文字换行失败
confirm_dialog({
title : '確認',
message : '以下XXを行います。\n\r \n \r <br>'+ ' ID:'+ row.id,
yes_cb : function(){
update(row);
},
no_cb : null,
});実施結果:/n ⇒空格, 作为字符串直接打印出来了
確認
以下XXを行います。 <br> ID:123方案:
1,\n\r 有効:white-space: pre-line;
2, 有効:&{}
1,CSS様式:white-space: pre-line;
css定义追加
.pre-line{
white-space: pre-line;
}confirm_dialog message定义部分:追加 class
<p class='pre-line'>{{message}}</p>2,使用 Template Literals(テンプレートリテラル)${}
<p>${context.message}</p>Template Literals:拼接字符串,包括变量,表达式,html templete
Interpolation 插值
Template literals provide an easy way to interpolate variables and expressions into strings.
The method is called string interpolation.
Template Literals is an ES6 feature (JavaScript 2015).It is supported in all modern browsers.
The syntax is:
${...}例:
// Variable Substitutions 变量置换
let firstName = "John";
let text = `Welcome ${firstName}, ${lastName}!`;
let text = `He's often called "Johnny"`; //Back-Tics Syntax, Quotes Inside Strings
let text = //Multiline Strings
`multiline
Strings`;
// Expression Substitution 表达式
let total = `Total: ${(price * (1 + rate)).toFixed(2)}`;
// HTML Templates
let html = `<h2>${header}</h2>`;补充:
边栏推荐
- 升级农企业务运营建设,智慧供应链管理平台打造“共赢生态链”
- Hanyuan Hi-Tech G8032 standard ERPS ring network switch Gigabit 4 optical 10 electrical industrial Ethernet switch ring network + WEB management + SNMP VLAN planning
- When Nodejs installation depends on cpnm, the install shows Error: Cannot find module 'fs/promises'
- 飞桨开源社区季度报告来啦,你想知道的都在这里
- An introduction to the pen tool, pencil tool and brush tool
- 优思学院|2022年获美质协ASQ和ILSSI奖项的《精益六西格玛的十条戒律》
- HCIP-第十二天-MPLS+VNP
- Golang 互斥锁
- 冷链行业商业供应链系统:实现全流程数字化协同,激活企业迸发市场活力
- [Microservice] Multi-level cache
猜你喜欢
随机推荐
d写二进制
An animation based button animation combined with basic code
d作者:d的新特性
OpenCV 透视变换
滑动窗口的最大值
Sogou news-数据集
An动画基础之散件动画原理与形状提示点
An animation optimization of shape tween and optimization of traditional tweening
【二叉树】统计最高分的节点数目
利用pgsql插件PostGIS 实现地理坐标系数据转换
PyTorch framework to train linear regression model (CPU and GPU environment)
半导体制造业回流美国?宏碁创始人施振荣:违反垂直分工大趋势
超大规模的产业实用语义分割数据集PSSL与预训练模型开源啦!
Golang 字典 map
农产品企业如何进行全网营销?
保健用品行业B2B电子商务系统:供采交易全链路数字化,助推企业管理精细化
An动画基础之元件的影片剪辑效果
[Blue Bridge Cup Trial Question 48] Scratch Dance Machine Game Children's Programming Scratch Blue Bridge Cup Trial Question Explanation
TiFlash 计算层概览
Notepad++ install jsonview plugin


![Tinymce plugins [Tinymce扩展插件集合]](/img/c6/da0782a4c85085cf7b5af86e249408.png)






