vue3 与 vue2 的区别

发布时间 2023-11-14 23:54:28作者: 王二疯

布尔型 Attribute​

布尔型 attribute 依据 true / false 值来决定 attribute 是否应该存在于该元素上。disabled 就是最常见的例子之一。

v-bind 在这种场景下的行为略有不同:

<button :disabled="isButtonDisabled">Button</button>

当 isButtonDisabled 为真值或一个空字符串(即<button disabled="">)时,元素会包含这个 disabled attribute。而当其为其他假值时 attribute 将被忽略。