-
ref最粗暴的获取子组件的所有方法以及元素等
父组件:
html:
<upload-img-s ref="img"></upload-img-s>
js:
handleImg(){
this.$refs.img.[子组件里的方法等]
}
-
$("upload:img",imgs)
父组件:
html:
<upload-img-s :hasImg.sync="imgR"></upload-img-s>
子组件:
js:
export default {
data(){
return{
}
},
props:{
hasImg:"",
},
methods:{
chooseImg() {
this.$emit("upload:hasImg",[子组件需要传过去的值])
}
}
}
-
使用$emit时间传值
父组件
js:
handleImg(item){
this.actForm.shopLogo = item
},
子组件
js:
this.$emit('handleImg', that.hasImg);