<el-table :data="tableData">
    <el-table-column label="备注" width="210" align="center">
	  <template slot-scope="scope">
	      <span>{{changeRemarkLength(scope.row.remark)}}</span>
	  </template>
    </el-table-column>
</el-table>


<script>
    data () {
        return {
	    tableData:[]
        }
    },
    methods: {
        
    },
    //计算属性
    computed:{
	//改变备注的长度,长度大于14位就用...代替剩余内容
	changeRemarkLength(){
	    //text就是所传参数
	    return function (text) {
		if(text.length > 14){
		    return text.slice(0,14)+"...";
		}else{
		    return text;
		}
	    }
	}
    }
</script>

说明:

         1、计算属性传参,方法里写成 return function (val) {}形式

          2、<template slot-scope="scope">  slot-scope="scope"代表插槽的意思,这里 scope 代表行 data。scope.row取整行数据

Logo

前往低代码交流专区

更多推荐