Confirm窗口$emit调用父窗口方法无效
发布于 3 年前 作者 chaoren 1349 次浏览 来自 问答
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利

1.父页面

<do-more @onreloadtab="reloadTab" :selectFolder="selectFolder"></do-more>
methods: {
      reloadTab:function(){
            console.log('reload')//这边无法调到
      }
}

2.子页面

<template>
  <span class="do-more">
    <el-dropdown
      size="mini"
      @visible-change="dropdownChange($event)"
      @command="dropdownCommon($event)"
    >
      <span class="el-dropdown-link">
        <el-button size="mini" type="text" icon="el-icon-more" class="triggleBtn"></el-button>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="delete">删除</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </span>
</template>

methods: {
      dropdownCommon: function (common) {
        if(common)
          eval("this." + common + "()");
      },
      delete:function (row) {
        let that = this
        this.$confirm("Are you sure to delete?", "confirm")
       .then((config) => {
             //调用父页面方法
             that.$emit('onreloadtab')
         })
          .catch(() => {
          });
}
回到顶部