Vue this.$confirm之后.then()里面给父组件传值的this.$emit不起作用

子组件给父组件传值,父组件中的data打印不出来

子组件中

this.$confirm('是否继续完善信息?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
}).then(() => {
    console.log('进入then');   //这个可以出来  
    this.$emit('listenTochildEvent','子组件传值');
}).catch(() => {
    this.$message({
        type: 'success',
        message: '可点击“完善”继续完善信息'
    });
});

父组件中

//Vue
<preparation-basic-detail-comp @listenTochildEvent="listenTochildEvent">
        </preparation-basic-detail-comp>

//JS
listenTochildEvent(data){
    console.log(data); //出不来
}
阅读 7.2k
2 个回答
✓ 已被采纳新手上路,请多包涵

好了 在this.$confirm前面加个阻塞await就好了,此贴终结

then里的this指向变了吧

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题