vue 数据传递

来源:互联网 发布:深圳石油软件 编辑:程序博客网 时间:2024/06/05 08:17

声明渲染目标(容器)

var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
},
methods:{
....
}
})

递归组件

Vue.component('unique-name-of-my-component', {
props:[' '],
template:' ',
methods:{
函数
}
})

父子组件间的通信

可以给声明渲染目标中写定所需所有函数,在递归组件中调用。

Vue.component('step-item', {
props:['step'],
template:' <div v-bind:class="step.class" ><i>{{step.text }}</i><input v-bind:type="step.type" v-on:click="changeColor($event)" v-bind:value="step.value"></div>',
methods:{
changeColor:funciton(event){
var value = event.target.valur; //获取当前的dom元素值
step.btnhit(this.step,this.step.ref,value); //this.step数据源,this.step.ref数据中的唯一值(key)
}
}
});
var step = new Vue({
el:'#fromBox',
data:{
class:"juget",
text:"内容",
type:"text",
value:""
},
methods:{
btnhit:function(data,key,value){
data.class = "show";
data.value="改变";
data.text = "i标签",
}
}
});

0 0