vue cope page

# 自定义页面的 class - vue cope

不要在选项 property 或回调上使用箭头函数,比如 created: () => console.log(this.a) 或 vm.$watch('a', newValue => this.myMethod())。因为箭头函数并没有 this,this 会作为变量一直向上级词法作用域查找,直至找到为止,经常导致 Uncaught TypeError: Cannot read property of undefined 或 Uncaught TypeError: this.myMethod is not a function 之类的错误。
1

Mustache 语法不能在 HTML attribute 中使用 ,然而,可以使用 v-bind 指令:

对于布尔 attribute (它们只要存在就意味着值为 true),v-bind 工作起来略有不同,在这个例子中:

如果 isButtonDisabled 的值是 null 或 undefined,则 disabled attribute 甚至不会被包含在渲染出来的 元素中。

当 v-bind:style 使用需要添加浏览器引擎前缀的 CSS property 时,如 transform,Vue.js 会自动侦测并添加相应的前缀。

当 v-if 与 v-for 一起使用时, vue2: v-for 具有比 v-if 更高的优先级。 vue3: v-if 具有比 v-for 更高的优先级。

结果:1 2 3 4 5 6 7 8 9 10

按键修饰符 常用的按键码的别名:.enter .tab .delete (捕获“删除”和“退格”键) .esc .space .up .down .left .right 通过全局 config.keyCodes 对象自定义按键修饰符别名: Vue.config.keyCodes.f1 = 112 系统修饰键 .ctrl .alt .shift .meta .exact 修饰符允许你控制由精确的系统修饰符组合触发的事件。