vue
1.子组件向父组件传递数据信息
通过$emit事件触发
例如:子组件 Vue.component(‘my-footer’,{
template:’
'<div class="share">'+
'<div class="img">'+
'<img src="../img/we-chat@3x.png" @click="show()">'+
'<img src="../img/weibo@3x.png" />'+
'</div>'+
'<p>分享至</p>'+
'</div>'+
'</div> ',
data:function(){
return {
share:false
}
},
methods:{
show(){
this.share= !this.share;
this.$emit("listen",this.share);
}
}
})
父组件
getEvent(data){
this.flag = data;
},
2.父组件向子组件传值 通过prop属性
//将子控件属性inputValue与父组件msg属性绑定
子组件:
复制代码
{{inputValue}}
vue
1.子组件向父组件传递数据信息
http://www.cnblogs.com/Zsmile/p/6256651.html
通过$emit事件触发
例如:子组件 Vue.component(‘my-footer’,{
template:’
'<div class="share">'+
'<div class="img">'+
'<img src="../img/we-chat@3x.png" @click="show()">'+
'<img src="../img/weibo@3x.png" />'+
'</div>'+
'<p>分享至</p>'+
'</div>'+
'</div> ',
data:function(){
return {
share:false
}
},
methods:{
show(){
this.share= !this.share;
this.$emit("listen",this.share);
}
}
})
父组件
getEvent(data){
this.flag = data;
},
2.父组件向子组件传值 通过prop属性
//将子控件属性inputValue与父组件msg属性绑定
子组件:
复制代码
{{inputValue}}
vue
1.子组件向父组件传递数据信息
http://www.cnblogs.com/Zsmile/p/6256651.html
通过$emit事件触发
例如:子组件 Vue.component(‘my-footer’,{
template:’
'<div class="share">'+
'<div class="img">'+
'<img src="../img/we-chat@3x.png" @click="show()">'+
'<img src="../img/weibo@3x.png" />'+
'</div>'+
'<p>分享至</p>'+
'</div>'+
'</div> ',
data:function(){
return {
share:false
}
},
methods:{
show(){
this.share= !this.share;
this.$emit("listen",this.share);
}
}
})
父组件
getEvent(data){
this.flag = data;
},
2.父组件向子组件传值 通过prop属性
//将子控件属性inputValue与父组件msg属性绑定
子组件:
复制代码
{{inputValue}}