父子组建通信代码demo
父页面 父页面编写handleUploadNew 接收子组建uploadNew 传上来的对象
父页面传递tempUrl 给子页面初始化数据
<Upload :temp-url="tempUrl" @uploadNew="handleUploadNew" />
子组件里面
<i class="el-icon-delete" @click="rmImage" />
props: {
tempUrl: {
type: String,
default: ''
}
},
handleImageSuccess(data) {this.tempUrl = 'https://xxxx.cn/' + data.keythis.file.url = this.tempUrlthis.file.path = data.keythis.$emit('uploadNew', this.file) //提交一个对象给父组件},