博主首页

vue2根据方法名调用方法,vue2根据方法名调用父组件方法

  methods:{
    dictByItem: function(item, row) {
      let dictElement = this.dict[item.dictName];
      let filter = dictElement.filter(i => i.value === row[item.prop] + '');
      return filter && filter.length > [0] ? filter[0].label : '';
    },
    functionByName: function(funcName,value){
      return this.$parent.$options.methods[funcName](value);
    }
  }
     <template v-else-if="item.type && item.type === 'func'">
        <el-table-column  :label="item.label" :prop="item.prop" v-bind="item.attr" >
          <template slot-scope="scope">
            <div>{{ functionByName(item.funcName,scope.row[item.prop])}}</div>
          </template>
        </el-table-column>
      </template>

 

posted @ 2025-01-16 18:25  笑~笑  阅读(17)  评论(0)    收藏  举报