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