Vue实例练习
来源:互联网 发布:centos mysql配置文件 编辑:程序博客网 时间:2024/06/14 00:40
多思考,其实没有看起来那么简单,你得想清楚。
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script></head><body> <p id="app-1"></p> <p id="app-2"></p></body><script> //this is an example to tell us 每个 Vue 实例都会代理其 data 对象里所有的属性 var data1={a:1}//js中的JSON格式,其中a 是Key, value 是 1 var vm=new Vue({ el:"#app-1", data:data1 }) vm.a === data1.a data1.a=3 //这些被代理的属性是响应的 document.write(vm.a) //定义在直接用类名(这里就是方法名)’.’一个方法,那么这个实际上创建的是一个静态方法; // 而用prototype’.’的一个方法,实际上创建的是一个实例方法,实例方法是需要创建实例对象进行访问的, //实例属性和方法与代理属性和方法 document.write(" "+vm.$data.a) document.write(" "+data1.a) // document.write(" "+vm.data.a)//wrong and no show ,Cannot read property 'a' of undefined // /document.write(" "+vm.data1.a)//wrong and no show var app2=new Vue({ el:"#app-2", data:{ a:1 }, created:function () { document.write(" "+"the app-2 living example create") }, mounted:function () { document.write(" "+"the el of app-2 living example change to app-3 ")//el 被新创建的 vm.$el 替换,并挂载到实例上去之后调用该钩子 }, updated:function () { document.write(" "+"the data of app-2 living example change ")//由于数据更改导致的虚拟 DOM 重新渲染和打补丁,在这之后会调用该钩子。 }, destoryed:function () { document.write(" "+"the app-2 living example destory ") } })</script></html>
阅读全文
0 0
- Vue实例练习
- vue实例
- Vue实例
- vue实例
- Vue实例
- vue 实例
- Vue实例
- Vue 实例
- Vue实例
- Vue 实例
- vue拖拽练习
- vue练习,写游戏
- vue 组件 小练习
- vue指令练习demo
- vue的bind练习
- vue的小练习
- vue ——Vue实例
- Vue基础之Vue实例
- HDU 1599 find the mincost route(Floyd无向图最小环)
- bzoj2209括号序列splay
- 暑假spring学习总结之初遇IoC
- 大型项目架构演变思想 由浅入深
- Spring/SpringMVC在启动完成后执行方法
- Vue实例练习
- oracle数据库想学点经验不是那么容易的看看总是好的
- [2017-08-25] 将MNIST数据集转换成图片形式并保存
- C++中关于输入cin、gets、getline等的一些整理
- Python入门学习记录—元组(tuple)
- 人工智能学习资源,你值得拥有!
- sql 注入及爆表与字段
- 阿里云实例安装https
- Linux系统管理---进程管理(查看进程、终止进程、更改进程优先级)