当前位置:网站首页>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>`;补充:
边栏推荐
- PyTorch构建神经网络预测气温(数据集对比,CPU与GPU对比)
- An animation basic element movie clip effect
- 汉源高科G8032标准ERPS环网交换机千兆4光10电工业以太网交换机环网+WEB管理+SNMP划VLAN
- Golang 数组和切片
- Nanoprobes金脂质偶联物的相关应用
- 升级农企业务运营建设,智慧供应链管理平台打造“共赢生态链”
- 软件测试面试(四)
- An introduction to the skeleton tool
- 短视频的头号玩家:抖音产品体验报告
- Nodejs 安装依赖cpnm时,install 出现Error: Cannot find module ‘fs/promises‘
猜你喜欢
随机推荐
【二叉树】统计最高分的节点数目
BOM系列之sessionStorage
升级农企业务运营建设,智慧供应链管理平台打造“共赢生态链”
An动画基础之元件的图形动画与按钮动画
365天挑战LeetCode1000题——Day 048 有序队列 脑筋急转弯
中国手机品牌争论谁是国内第一,而它已成为中国手机在海外的代表
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?
PyTorch framework to train linear regression model (CPU and GPU environment)
An工具介绍之钢笔工具、铅笔工具与画笔工具
Golang sync.WaitGroup
ITSM软件与工单系统的区别是什么?
国产替代风潮下,电子元器件B2B商城系统如何助力企业突围市场竞争
HCIP 第十六天笔记(SVI、生成树协议)
[R] Use grafify for statistical plotting, ANOVA, intervention comparisons, and more!
类和对象(中下)
An动画优化之遮罩层动画
软件测试自学还是报班好?
OpenCV 透视变换
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
IronOS, an open source system for portable soldering irons, supports a variety of portable DC, QC, PD powered soldering irons, and supports all standard functions of smart soldering irons







