需要利用vue的插槽slot,這是官方的例子:
template結(jié)構(gòu)內(nèi)的
methods內(nèi)輸入的
通過<template slot-scope=“scope”>來定義當(dāng)前行的數(shù)據(jù)對象,然后通過scope.row來獲取當(dāng)前行的數(shù)據(jù)
我的例子:
template結(jié)構(gòu)內(nèi)的
methods內(nèi)輸入的
console.log(row)的row即是當(dāng)前行的所有數(shù)據(jù)
具體實(shí)現(xiàn)效果:
點(diǎn)擊查看后log打印的:
想獲取地址就const address = row.address,想獲取年紀(jì)就const age = row.age,就是這樣。