当前位置:网站首页>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>`;补充:
边栏推荐
猜你喜欢
随机推荐
Postman插件下载
d写二进制
不卷不pua,早9晚6,这个招聘深得我心
PyTorch framework to train linear regression model (CPU and GPU environment)
OpenCV perspective transform
使用百度EasyDL实现施工人员安全装备检测
Redis 6 的多线程
An动画基础之元件的图形动画与按钮动画
如何合理安排一天,做到高效备考?
HCIP第十五天笔记(企业网的三层架构、VLAN以及VLAN 的配置)
Heaps
Nature, Cell都在用的Relia Tech 抗原亲和纯化LYVE1抗体
冷链行业商业供应链系统:实现全流程数字化协同,激活企业迸发市场活力
Nanoprobes Ni-NTA-Nanogold——用于 His 标签标记和检测
投资75亿卢比!印度宣布建首座存储芯片组装和封测工厂,将于12月量产
Insertion or Heap Sort
An introduction to the camera
An基本工具介绍之选择线条工具(包教会)
设计思维 | 详看设计工作坊Workshop的11个关键技巧
【二叉树】从二叉树一个节点到另一个节点每一步的方向









