当前位置:网站首页>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>`;补充:
边栏推荐
- Nodejs 安装依赖cpnm时,install 出现Error: Cannot find module ‘fs/promises‘
- 不卷不pua,早9晚6,这个招聘深得我心
- Comics: how do you prove that sleep does not release the lock, and wait to release lock?
- leetcode16 Sum of the closest three numbers (sort + double pointer)
- 细胞图像数据的主动学习
- 金立前高管团队再战手机市场,创立新品牌“FreeYond”
- 利用pgsql插件PostGIS 实现地理坐标系数据转换
- An animation optimization of traditional guide layer animation
- tinymce 如何实现动态国际化
- 工具模板 | 用APOEM方法消除对用户行为的偏见
猜你喜欢

365天挑战LeetCode1000题——Day 048 有序队列 脑筋急转弯

An工具介绍之钢笔工具、铅笔工具与画笔工具

An animation basic element movie clip effect

Jmeter use

Notepad++ install jsonview plugin

svn安装包和客户端

中国手机品牌争论谁是国内第一,而它已成为中国手机在海外的代表

技术分享 | 接口自动化测试如何搞定 json 响应断言?

Hanyuan Hi-Tech G8032 standard ERPS ring network switch Gigabit 4 optical 10 electrical industrial Ethernet switch ring network + WEB management + SNMP VLAN planning

【OpenCV】 级联分类器训练模型
随机推荐
不卷不pua,早9晚6,这个招聘深得我心
【OpenCV】 级联分类器训练模型
如何合理安排一天,做到高效备考?
Golang arrays and slices
细胞图像数据的主动学习
Nanoprobes EnzMet - 酶金相相关介绍及应用
An工具介绍之摄像头
tinymce 如何实现动态国际化
工具模板 | 用APOEM方法消除对用户行为的偏见
An工具介绍之3D工具
BOM系列之sessionStorage
An introduction to the camera
OpenCV perspective transform
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
国产替代风潮下,电子元器件B2B商城系统如何助力企业突围市场竞争
d写二进制
可视化图表设计Cookbook
安全狗《云原生安全威胁分析报告》首次提出双检测模型
飞桨开源社区季度报告来啦,你想知道的都在这里
【OpenCV】 书本视图矫正 + 广告屏幕切换 透视变换图像处理