今天在项目中遇到一个问题,就是自己封装好了组件,但是引用那个组件时别的东西都能显示,就是formmter一直没用,后面发现是template中插槽作用域导致的,
<el-table-column v-for="(item,index) in columns" :key="index" :prop="item.prop" :label="item.label" :width="item.width" :min-width="item.minWidth" :formatter="item.formatter">
<template slot-scope="scope">
<slot v-if="item.scopeName" :name="item.scopeName" :scope="scope" />
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
</el-table-column>
后面改成 就可以了
<el-table-column v-for="(item,index) in columns" :key="index" :prop="item.prop" :label="item.label" :width="item.width" :min-width="item.minWidth" :formatter="item.formatter">
</el-table-column>