摘要:
data:{ weather:25, wear:'短袖' } 实例属性写watch监控 构造器外部写法 app.$watch('xxx',function(){}) 写在构造器里 watch:{ weather:function(nv,ov){ } } 用computed实现 就不灵活了。例 com 阅读全文
posted @ 2020-05-04 23:46
老韩哥
阅读(149)
评论(0)
推荐(0)
|
摘要:
data:{ weather:25, wear:'短袖' } 实例属性写watch监控 构造器外部写法 app.$watch('xxx',function(){}) 写在构造器里 watch:{ weather:function(nv,ov){ } } 用computed实现 就不灵活了。例 com 阅读全文
posted @ 2020-05-04 23:46
老韩哥
阅读(149)
评论(0)
推荐(0)
摘要:
1、传值 add(2) 2、event add(2,$event) 3、组件调用 click方法 @click.native="add()" 4、构造器外部click方法 app.add() methods:{ add:function(step,event){ if(!step==''){ thi 阅读全文
posted @ 2020-05-04 20:46
老韩哥
阅读(178)
评论(0)
推荐(0)
摘要:
computed 的作用主要是对原数据进行改造输出 比如:拼接字符串 ¥100元 data:{ price:100, news:newList }, computed:{ newPrice:function(){ return this.price="¥"+this.price+“元” } } 比如 阅读全文
posted @ 2020-05-04 18:16
老韩哥
阅读(157)
评论(0)
推荐(0)
摘要:
propsData 不是和属性有关,他用在全局扩展时进行传递数据。 先写一个全局扩展 var header_a = Vue.extend({ template:`{{message}} 传值 {{ a }}`, data:function(){ return { message:"内容" } }, 阅读全文
posted @ 2020-05-04 14:27
老韩哥
阅读(1406)
评论(0)
推荐(0)
摘要:
component 标签 Vue框架自定义的标签,它的用途就是可以动态绑定我们的组件,根据数据的不同更换不同的组件。 例: 1、自定义3个组件 var cpA={ template:`<div>我是组件A</div>` } ... 2、在构造器里挂载组件 components:{ "cpA":cpA 阅读全文
posted @ 2020-05-04 12:08
老韩哥
阅读(1365)
评论(0)
推荐(0)
摘要:
<father></father> 声明一个对象,对象里就是组件的内容 子组件 var sun={ template:`<p>我是儿子</p>` } 父组件 var father={ template:` <div> <p>我是父亲</p> <sun></sun> </div> ` //父级里注册子 阅读全文
posted @ 2020-05-04 10:54
老韩哥
阅读(358)
评论(0)
推荐(0)
摘要:
定义属性我们需要用props选项,加上数组形式的属性名称,例如:props:[‘here’] components:{ "laohan":{ template:``, props:[] } } 如果属性名称里有“-” 要用小驼峰式写法props:[‘formHere’] 这时我们可以给属性bind 阅读全文
posted @ 2020-05-04 10:23
老韩哥
阅读(984)
评论(0)
推荐(0)
摘要:
全局 顾名思义就是在构造器外面声明的 <laohan></laohan> Vue.component('laohan',{ template:`<div>我是全局的标签组件</div>` }) 局部 在构造器里面 以选项的方式 <seodream></seodream> components:{ " 阅读全文
posted @ 2020-05-04 10:07
老韩哥
阅读(221)
评论(0)
推荐(0)
摘要:
目前学习了三种方法 第一种 vue选项模板 template:` <h2>我是选项模板</h2> ` 第二种标签模板 <template id="tp2"> <h2>我是标签模板</h2> </template> template:"#tp2" 第三种script模板 <script-type="x 阅读全文
posted @ 2020-05-04 09:16
老韩哥
阅读(182)
评论(0)
推荐(0)
摘要:
beforeCreate,created,beforeMount,mounted,beforeUpdate,updated,activated,deactivated,beforeDestory,destoryed beforeCreate: function() { console.log('1- 阅读全文
posted @ 2020-05-04 08:21
老韩哥
阅读(154)
评论(0)
推荐(0)
|