本文共 1586 字,大约阅读时间需要 5 分钟。
Vue.js是一款基于数据驱动的前端框架,具有以下核心特点:
以下是获取Vue.js相关资源的推荐链接:
创造一个Vue实例:
new Vue({ el: '#app', template: '{msg}', data: { msg: 'Hello Vue' }})
v-on
和v-on:keydown.enter
或@
缩写v-bind
和:class
结合数据逻辑Vue.set
或Array.prototype.splice
方法实现$emit
方法触发事件,父子组件通过@
监听this.$emit
$slots
传递内容和数据<component v-bind:is="currentView">
实现对缓存的处理可以使用<keep-alive>
包裹组件实现
v-if
和v-else
实现条件渲染.stop
和.prevent
修饰符<transition>
组件实现过度效果routes
数组实现多级页面跳转$watch
方法v-once
指令v-bind
和v-on
的省略形式合理使用computed
属性替代watch
,避免不必要的复杂性
computed
适用于基于其他属性计算的场景watch
适用于需要直接观察数据的场景v-if
和v-else
v-else如果
和v-if
结合push
、pop
、shift
等方法将触发视图更新v-model.lazy
优化输入绑定v-model.number
自动转换数据类型v-model.trim
清除首尾空格Vue.directive
binding
对象处理v-model
结合filters
实现json-server
实现快速API伪造new Vue
前执行Vue.set
实现响应式通过以上内容,可以系统性地掌握Vue.js的核心知识点和实践技巧。
转载地址:http://iuhcz.baihongyu.com/