当前位置:网站首页>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>`;
补充:
边栏推荐
猜你喜欢
365天挑战LeetCode1000题——Day 048 有序队列 脑筋急转弯
[Deep Learning] Overview of Efficient and Lightweight Semantic Segmentation
An工具介绍之宽度工具、变形工具与套索工具
secureCRT连接开发板连接不上问题解决
Classes and objects (upper)
【蓝桥杯选拔赛真题48】Scratch跳舞机游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
Postman插件下载
如何合理安排一天,做到高效备考?
第07章 InnoDB数据存储结构【2.索引及调优篇】【MySQL高级】
欧曼自动挡、银河大马力、行星新产品 欧曼全新产品以燎原之势赢领市场
随机推荐
An animation basic element movie clip effect
优思学院|2022年获美质协ASQ和ILSSI奖项的《精益六西格玛的十条戒律》
Yahoo! Answers-数据集
冷链行业商业供应链系统:实现全流程数字化协同,激活企业迸发市场活力
Golang channel channel
易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元
In order to counteract the drop in sales and explore the low-end market, Weilai's new brand products are priced as low as 100,000?
leetcode 11. 盛最多水的容器
An动画基础之元件的图形动画与按钮动画
Nanoprobes EnzMet - 酶金相相关介绍及应用
d写二进制
Nanoprobes FluoroNanogold 偶联物的特色和应用
An动画优化之补间形状与传统补间的优化
国产替代风潮下,电子元器件B2B商城系统如何助力企业突围市场竞争
Win11怎么禁止软件后台运行?Win11系统禁止应用在后台运行的方法
An动画优化之遮罩层动画
如何让history历史记录前带时间戳
An introduction to the width tool, deformation tool and lasso tool
An动画基础之元件的影片剪辑动画与传统补间
leetcode16 Sum of the closest three numbers (sort + double pointer)