vue.js - vuejs $emit 在确认对话框中无效
问题描述
我尝试从父页面获取子页面发送的请求,但是不成功。</p>
1.父代号
<do-more @onreloadtab="reloadTab" :selectFolder="selectFolder"></do-more>
methods: {
reloadTab:function(){
console.log('reload')
}
}
2.子代码
methods: {
async delete (row) {
let that = this
await this.$confirm("Are you sure to delete?", "confirm")
.then((config) => {
that.$emit('onreloadtab')
return
})
.catch(() => {
});
}
为什么父母不能得到发射消息?
解决方案
使用后不需要使用then
方法await
。该then
方法在 Promise 之后调用,但await
返回的是 Promise内部的值,而不是 Promise。因此,请尝试在没有方法块的语句emit
之后调用。await
then
推荐阅读
- go - 发送udp包时如何设置源端口
- javascript - 在 HTML 中使用变量值时如何在悬停时显示 href,
- laravel - Laravel - 未找到列:Laravel 查询中的 1054 列未知
- machine-learning - 使用 BERT 对给定的字符长度或句子中的单词数进行分类
- axapta - Dynamics AX V4 兼容性
- python - Python3 - Doc2Vec:按向量/ID 获取文档
- java - opengl中z坐标的值是多少
- scala - Spark Transformers [Scala]:在提供完整数据之前了解模式转换结果
- c# - 如何按不同的分组聚合 linq 查询
- rust - serde json 反序列化任何数字