01_HelloWorld
hello {{msg}}
02_模板语法
03_计算属性和监视
姓:
名:
姓名1(单向):
姓名2(单向):
姓名3(双向):
{{fullName1}}
{{fullName1}}
04_class与style绑定
1. class绑定: :class='xxx'
xxx是字符串
xxx是对象
xxx是数组
2. style绑定
:style="{ color: activeColor, fontSize: fontSize + 'px' }"
08_条件渲染
表白成功
表白失败
求婚成功
求婚失败
06_列表渲染
测试: v-for 遍历数组
-
{{index}}--{{p.name}}--{{p.age}}
--
--
测试: v-for 遍历对象
- {{key}}={{item}}
06_列表渲染_过滤与排序
-
{{index}}--{{p.name}}--{{p.age}}
07_事件处理
08_表单输入绑定
09_Vue实例_生命周期
尚硅谷IT教育
10_过渡&动画1
hello
hello
10_过渡&动画2
Lorem
11_过滤器
显示格式化的日期时间
{{time}}
最完整的: {{time | dateString}}
年月日: {{time | dateString('YYYY-MM-DD')}}
Vue.directive('upper-text', function (el, binding) {
console.log(el, binding)
el.textContent = binding.value.toUpperCase()
})
directives : {
'my-directive' : {
bind (el, binding) {
el.innerHTML = binding.value.toupperCase()
}
}
}
// 声明使用插件(安装插件: 调用插件的install())
// 内部会调用插件对象的install()
Vue.use(MyPlugin)
const vm = new Vue({
el: '#test',
data: {
msg: 'HaHa'
}
})
Vue.myGlobalMethod()
vm.$myMethod()
(function (window) {
const MyPlugin = {}
MyPlugin.install = function (Vue, options) {
// 1. 添加全局方法或属性
Vue.myGlobalMethod = function () {
console.log('Vue函数对象的myGlobalMethod()')
}
// 2. 添加全局资源
Vue.directive('my-directive',function (el, binding) {
el.textContent = 'my-directive----'+binding.value
})
// 4. 添加实例方法
Vue.prototype.$myMethod = function () {
console.log('vm $myMethod()')
}
}
window.MyPlugin = MyPlugin
})(window)