computed: {
searchData: function() {
var search = this.search;
//此处的etquestions均为data, 这个etquestions.content.title是根据自己的需要写,一般写data
if (search) {
return this.etquestions.filter(etquestions => {
if (etquestions.content.title.includes(search)) {
return etquestions;
}
});
}
return this.etquestions;
}
}
<el-table
class="question-tab"
style="width: 100%"
:show-header="false"
:data="searchData" //把data换成computed中定义的方法,会返回一个data
@selection-change="handleSelectionChange"
>
</el-table>