本篇文章給大家分享的是有關(guān)ant design vue中表格如何實(shí)現(xiàn)指定格式渲染,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
渲染方法1:
指定渲染函數(shù):
const columns = [ { title: '排名', dataIndex: 'key', customRender: renderContent // 渲染函數(shù)的規(guī)則 }, { title: '搜索關(guān)鍵詞', dataIndex: 'keyword', customRender: (text, row, index) => { if (index < 4) { // 前4行數(shù)據(jù)以a標(biāo)簽的形式被渲染 return {text} } return { // 否則以獨(dú)占4列的文本形式被渲染 children: text, attrs: { colSpan: 4 } } } } ] const renderContent = (value, row, index) => { const obj = { children: value, attrs: {} } return obj }