首页 > 编程知识 正文

html中的双引号怎么弄,html中字符引号用什么表示

时间:2023-05-03 18:09:25 阅读:180676 作者:510

ES6提供了一种使用反向标记作为分隔符的新类型的字符串文本。 这些文本可以嵌入基本的字符串插值表达式,并自动分析和评估。

let person={ name : ' rajinikanth ',age:68,greeting:'Thalaivaaaa!' (;

let usualHtmlStr='

My name is ' person.name ',

n' ' I am ' person.age ' old

n' ' ""+ person.greeting +"" is what I usually say'; let newHtmlStr=

`

My name is ${person.name},

I am ${person.age} old

"${person.greeting}" is what I usually say`;

console.log(usualhtmlstr;

console.log(newhtmlstr; 如您所见,我们在一系列字符周围使用了`。 虽然这些字符被解释为字符串文字,但${.}格式的任何表达式都会立即进行内联分析和评估。 对字符串文字进行插值的一个非常好的优点是可以将其拆分为多行。

varactor={ ' name ' : ' rajinikanth ' };

vartext=` nowisthetimeforallgoodmenlike $ { actor.name } tocometotheaidoftheircountry! `;

console.log(Text;

//nowisthetimeforallgoodmentocometotheaidoftheircountry!

使用ES6 :

字符串可以跨越多行。

不需要转义引号中的字符。

可以避免分组: "

不需要加号运算符。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。