vue formatter返回html,vue中使用element table,表格参数格式化formatter

element table formatter

解决办法:仔细看官网

element table formatter

template

:data="tableData"

ref="singleTable"

highlight-current-row

style="width: 100%">

type="index"

:index = "indexMethod"

width="50">

prop="date"

label="日期"

width="180"

>

prop="sex"

label="性别"

width="180"

:formatter="formatSex"

>

prop="name"

label="姓名"

width="180">

prop="address"

label="地址"

width="180">

size="mini"

@click="handleEdit(indexMethod(scope.$index), scope.row)">编辑

size="mini"

type="danger"

@click="handleDelete(indexMethod(scope.$index), scope.row)">删除

data

tableData: [{

myIndex: 6,

date: '2016-05-02',

name: '王小虎',

address: '上海市普陀区金沙江路 1518 弄',

sex: 0

}, {

myIndex: 7,

date: '2016-05-04',

name: '王小虎',

address: '上海市普陀区金沙江路 1517 弄',

sex: 1

}, {

myIndex: 8,

date: '2016-05-01',

name: '王小虎',

address: '上海市普陀区金沙江路 1519 弄',

sex: -1

}, {

myIndex: 9,

date: '2016-05-03',

name: '王小虎',

address: '上海市普陀区金沙江路 1516 弄',

sex: 0

}]

methods

formatSex: function (row, column) {

return row.sex === 1 ? '男' : row.sex === 0 ? '女' : '未知'

}

你可能感兴趣的:(vue,formatter返回html)