js文件, 这里需要根据this.activeTab判断fixed是否right固定,但是这样是拿不到this的,需要在vue中调用commonColumns()方法的时候把this传进来
export function commonColumns() {
return [
{
label: '序号',
type: 'index',
reserveIndex: true,
width: 45,
},
{
label: '意见',
prop: 'reason',
width: 150,
fixed: this.activeTab === '10' ? 'right' : false,
},
{
label: '操作日志',
prop: 'operationLog',
},
];
}
// 先把这玩意引进来
import { commonColumns } from './constants';
computed: {
columns() {
switch (+this.activeTab) {
default:
// 然后用的时候把this传过去
return commonColumns.call(this);
}
},