当前位置:网站首页>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>`;补充:
边栏推荐
- 漫画:怎么证明sleep不释放锁,而wait释放锁?
- 冷链行业商业供应链系统:实现全流程数字化协同,激活企业迸发市场活力
- [Deep Learning] Overview of Efficient and Lightweight Semantic Segmentation
- PyTorch builds a classification network model (Mnist dataset, fully connected neural network)
- 国产替代风潮下,电子元器件B2B商城系统如何助力企业突围市场竞争
- An animation optimization of traditional guide layer animation
- 硬件业务收入下滑,为了赚钱,苹果暧昧对待流氓软件和增加广告了
- Nanoprobes 金纳米颗粒标记试剂丨1.4 nm Nanogold 标记试剂
- An动画基础之按钮动画与基础代码相结合
- leetcode 11. 盛最多水的容器
猜你喜欢

漫画:怎么证明sleep不释放锁,而wait释放锁?

An动画基础之元件的影片剪辑动画与传统补间

An animation optimization of shape tween and optimization of traditional tweening
![[OpenCV] Book view correction + advertising screen switching Perspective transformation image processing](/img/8e/0e8e4e2b362ebdeb071efbf995fc89.png)
[OpenCV] Book view correction + advertising screen switching Perspective transformation image processing

An introduction to the skeleton tool
![[Blue Bridge Cup Trial Question 48] Scratch Dance Machine Game Children's Programming Scratch Blue Bridge Cup Trial Question Explanation](/img/4c/b41d64c13d6903aa38cc46dea44519.png)
[Blue Bridge Cup Trial Question 48] Scratch Dance Machine Game Children's Programming Scratch Blue Bridge Cup Trial Question Explanation

Sogou news - dataset

An动画优化之遮罩层动画

易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元

An工具介绍之形状工具及渐变变形工具
随机推荐
厨卫电器行业数字化集采管理系统:优化产业供应结构,实现采购业务流程集中管控
Golang sync.WaitGroup
How to make the history record time-stamped before
GameFi industry down but not out | June Report
secureCRT连接开发板连接不上问题解决
An工具介绍之3D工具
Sogou news - dataset
Graphic animation and button animation of an animation basic component
An工具介绍之宽度工具、变形工具与套索工具
Postman插件下载
tinymce 如何实现动态国际化
An动画优化之补间形状与传统补间的优化
MySQL数据表操作实战
An introduction to the pen tool, pencil tool and brush tool
[OpenCV] Cascade classifier training model
ECCV 2022 | AirDet: 无需微调的小样本目标检测方法
The components of the basis of An animation movie clip animation between traditional filling
leetcode 448. Find All Numbers Disappeared in an Array 找到所有数组中消失的数字(简单)
An工具介绍之形状工具及渐变变形工具
An introduction to the camera