摘要:1、写一个模板 <template id="tmp"> <div> <p>博客地址:</p> <p>网名:</p> <p>技术类型:</p> </div> </template> 2、写一个组件 var author={ template:"#tmp" } components:{ "author"
阅读全文
随笔分类 - vue2.0学习笔记
VUE2.0学习
摘要:1、写一个模板 <template id="tmp"> <div> <p>博客地址:</p> <p>网名:</p> <p>技术类型:</p> </div> </template> 2、写一个组件 var author={ template:"#tmp" } components:{ "author"
阅读全文
摘要://写入方法 app.$on('reduce',function(){ this.count-- }) // 调用 function reduce(){ app.$emit('reduce') } //写入方法 app.$once('reduceOnce',function(){ this.coun
阅读全文
摘要:挂载方法 vm.$mount('xx') 卸载方法 vm.$destroy(); 更新方法 vm.$forceUpdate() 数据修改方法 function tick(){ vm.message="update message info "; vm.$nextTick(function(){ co
阅读全文
摘要:如何调用 jQuery 1、引入jQuery 文件 2、在 mounted 或 updated 里调用 //在Vue中使用jQuery mounted:function(){ $('#app').html('我是jQuery!'); }
阅读全文
摘要:通过外部增加对象的形式,对构造器进行扩展 var exUpdate={} 构造器里 extends:exUpdate 如果方法重名,则优先处理原生的方法。 delimiters delimiters:['${','}'] 作用是改变我们插值的符号。Vue默认的插值是双大括号{{}}。但有时我们会有需
阅读全文
摘要:全局 Vue.mixin({ updated:function(){} }) 外部 var mxUpdate={ updated:function(){} } mixins:[mxUpdate] 原生 updated:function(){} 执行顺序:全局 - 外部 - 原生 从执行的先后顺序来说
阅读全文
摘要:data:{ weather:25, wear:'短袖' } 实例属性写watch监控 构造器外部写法 app.$watch('xxx',function(){}) 写在构造器里 watch:{ weather:function(nv,ov){ } } 用computed实现 就不灵活了。例 com
阅读全文
摘要: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
阅读全文
摘要:computed 的作用主要是对原数据进行改造输出 比如:拼接字符串 ¥100元 data:{ price:100, news:newList }, computed:{ newPrice:function(){ return this.price="¥"+this.price+“元” } } 比如
阅读全文
摘要:propsData 不是和属性有关,他用在全局扩展时进行传递数据。 先写一个全局扩展 var header_a = Vue.extend({ template:`{{message}} 传值 {{ a }}`, data:function(){ return { message:"内容" } },
阅读全文
摘要:component 标签 Vue框架自定义的标签,它的用途就是可以动态绑定我们的组件,根据数据的不同更换不同的组件。 例: 1、自定义3个组件 var cpA={ template:`<div>我是组件A</div>` } ... 2、在构造器里挂载组件 components:{ "cpA":cpA
阅读全文
摘要:<father></father> 声明一个对象,对象里就是组件的内容 子组件 var sun={ template:`<p>我是儿子</p>` } 父组件 var father={ template:` <div> <p>我是父亲</p> <sun></sun> </div> ` //父级里注册子
阅读全文
摘要:定义属性我们需要用props选项,加上数组形式的属性名称,例如:props:[‘here’] components:{ "laohan":{ template:``, props:[] } } 如果属性名称里有“-” 要用小驼峰式写法props:[‘formHere’] 这时我们可以给属性bind
阅读全文
摘要:全局 顾名思义就是在构造器外面声明的 <laohan></laohan> Vue.component('laohan',{ template:`<div>我是全局的标签组件</div>` }) 局部 在构造器里面 以选项的方式 <seodream></seodream> components:{ "
阅读全文
摘要:目前学习了三种方法 第一种 vue选项模板 template:` <h2>我是选项模板</h2> ` 第二种标签模板 <template id="tp2"> <h2>我是标签模板</h2> </template> template:"#tp2" 第三种script模板 <script-type="x
阅读全文
摘要:beforeCreate,created,beforeMount,mounted,beforeUpdate,updated,activated,deactivated,beforeDestory,destoryed beforeCreate: function() { console.log('1-
阅读全文
摘要:{{count}}<button type="button" onclick="add()">ADD</button>我们用3种方法改变count值function add(){ //直接操作外部数据 outData.count++ //用Vue对象的方法添加 app.count++ //用Vue.
阅读全文
摘要:需求是这样的,要在博客页面多处显示作者的网名,并在网名上直接有链接地址。 我们希望在html中只需要写<author></author>,这和自定义组件很像,但是他没有传递任何参数,只是个静态标签。 var myExtend = Vue.extend({ //模板 template:"" //数据
阅读全文
摘要:<div v-laohan="font">元素</div> 需要在构造器外执行 Vue.directive('my',function(el,binding,vnode){ console.log(el) //<div>元素</div> console.log(binding) //object c
阅读全文
摘要:v-pre 直接输出源码 {{name}} v-cloak 渲染完成后再展示 它必须和CSS样式一起使用 [v-cloak] { display: none; } v-once 第一次DOM时进行渲染,渲染完成后视为静态内容,跳出以后的渲染过程
阅读全文
|