http://cn.vuejs.org
https://github.com/vuejs/vue
https://github.com/vuejs
var my = new vue({ el: '#app', template: '<div>{{}}</div>', data:{ fruit: 'apple' } })
//绑定键盘按下enter事件 v-on:keydown.enter="" v-on缩写@ :class="{odd:index%2}" 判断odd什么时候需要显示出来 v-bind:缩写: //修改数组 vue.set(this.list, 1, { name: 'pinaapple', price: 256 }) this.$emit("xxx") 子组件提交事件,父组件可以监听 watch:{ } 用来监听数据变化
子组件调用父方法 父组件 @my-event="getmyevent"绑定方法 监听事件 子组件 触发方法,传入参数 methods: { emitmyevent(){ this.$emit('my-event', this.hello) } } 父组件调用子方法 父组件 componenta number='12' @my-event="getmyevent"> <p slot="header">header</p>//插槽 <p slot="footer">footer</p> </componenta> 子组件 <div>{{number}}</div> <slot name="header">no header</slot> <slot name="footer">no footer</slot> props: { number:[number,string] } 动态绑定组件 <p :is="currentview"></p> import coma from './components/a' components: { coma }, data:{ currentview: 'com-a' }
<keep-alive></keep-alvie>包裹
https://mobaxterm.mobatek.net/
http://www.hostbuf.com
main.js routes: [ { path: '/apple/:color', component: apple },{ path: '/banana', component: banana } ] apple.vue methods: { getparams(){ console.log(this.$route.params) } }
// $watch 是一个实例方法 vm.$watch('a', function (newvalue, oldvalue) { // 这个回调将在 `vm.a` 改变后调用 }) <span v-once>这个将不会改变: {{ msg }}</span> v-bind缩写 <!-- 完整语法 --> <a v-bind:href="url">...</a> <!-- 缩写 --> <a :href="url">...</a> v-on缩写 <!-- 完整语法 --> <a v-on:click="dosomething">...</a> <!-- 缩写 --> <a @click="dosomething">...</a>
https://cn.vuejs.org/v2/guide/computed.html
不要滥用watch,有时候可以用computed代替
<div v-bind:class="{ active: isactive }"></div> 上面的语法表示 active 这个 class 存在与否将取决于数据属性 isactive 的 truthiness。
<div v-bind:class="[activeclass, errorclass]"></div> data: { activeclass: 'active', errorclass: 'text-danger' } 渲染为: <div class="active text-danger"></div> 可以用三元表达式 <div v-bind:class="[isactive ? activeclass : '', errorclass]"></div>
https://cn.vuejs.org/v2/guide/conditional.html
<h1 v-if="awesome">vue is awesome!</h1> <h1 v-else>oh no
您可能感兴趣的文章:
如对本文有疑问, 点击进行留言回复!!
selenium + ajax抓取英雄联盟全部英雄的详细信息及多线程保存全部皮肤图片到本地
网友评论