小编pdw*_*jun的帖子

$emit 回调完成后的 vue

在组件中,当调用$emit('callback', params)完成时,我需要返回值。有人可以帮忙吗?

Vue 组件:

    methods: {
        test: function () {
            if(this.$emit('cb', param1)){
                // this not working
                console.log('return true')
            }else{
                console.log('return false')
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

vueRoot:

methods: {
        cb: function () {
            return true;
        }
    }
Run Code Online (Sandbox Code Playgroud)

emit vue.js

2
推荐指数
1
解决办法
9257
查看次数

标签 统计

emit ×1

vue.js ×1