普通字面量 " 里嵌套 ' 就可以<div :content="{ name: 'White', text: 'hello!' }"></div>但是假如 text 里也有双引号要怎么嵌套(不使用变量)<div :content="{ name: 'White', text: 'say "hello!"' }"></div>不使用变量的原因:比如在页面中有大量分布且没有关联的类似代码,在 data 里堆砌一大堆变量并不能改善可维护性(看到变量,你还要去找实际变量用在哪个地方,离散且没有关联的情况下毫无益处),都放一个对象里,其实又没什么关联性
2 回答

慕桂英3389331
TA贡献2036条经验 获得超8个赞
和普通js的一样啊
// 方法一<div :content="{ name: 'White', text: 'say \"hello!\"' }"></div>// 方法er<div :content="{ name: 'White', text: `say "hello!"` }"></div>
添加回答
举报
0/150
提交
取消