active-value 和 : active-value 什么时候前面加冒号?
如果要求【active-value】值类型为 number 时,必须在其前面加上 :
①加冒号的,说明后面的是一个变量或者表达式;
②没加冒号的,后面就是对应的字符串字面量!
冒号绑定值的问题
在 vue 中绑定属性值时,比如:
<el-dialog :title="dialogTitle"></el-dialog>
①若title前不加冒号:
<el-dialog title="dialogTitle"></el-dialog>
会被当做 html 文本处理成字符串,也就是 title 最终渲染出来是字符串 “dialogTitle”
②若title前加冒号:
<el-dialog :title="dialogTitle"></el-dialog>
会被当做模板处理,在渲染的时候会进行相应的填值处理。
- 所以:
当 dialogTitle 处为数值、布尔值时,必须要在 title 前加上冒号,比如:
<el-dialog :title="true"></el-dialog>
<el-dialog :title="657"></el-dialog>
- 否则会被当成字符串 true 和字符串 657。
Note:
欢迎点赞,留言,转载请在文章页面明显位置给出原文链接
知者,感谢您在茫茫人海中阅读了我的文章
没有个性 哪来的签名!
详情请关注点我
持续更新中
© 2022 06 - Guyu.com | 【版权所有 侵权必究】 |