父组件, fetch-method是函数
<DataTable ref="table" :table-data="deviceTable" :show-columns="deviceColumns" :selectable="true" :pageSize="filter.pageSize" :total="filter.total" :fetch-method="getDeviceList" @filter-table="filterTable" @handle-view="handleView" /> methods: { // 获取设备列表 getDeviceList(obj) { console.log(obj) const filter = cloneDeep(this.filter); // console.log(params); const params = {...filter, ...obj} console.log(params, 'params'); return assetManage.getDevicesPost(params).then((res) => { const { items, total } = res.data; this.deviceTable = items; this.filter.total = total; return { items, total } }); },
子组件
接受该函数 props: { fetchMethod: { type: Function, default: () => {}, }, // methods: { 子组件调用父组件的函数 getList() { this.fetchMethod({ order_by: this.orderBy, pageNo: this.currentPage, pageSize: this.realPageSize, }).then((res) => { console.log(res, "res"); const { total, items } = res; this.total = total; this.tableData = items; }); },
参考文章:https://blog.csdn.net/joyvonlee/article/details/108754662
热门文章
- Java中Stack.peek()与Stack.pop()与Queue.poll的区别
- 宠物粮食品牌起名大全四个字的名字 宠物粮食品牌起名大全四个字的名字有哪些
- 「2月28日」最高速度18.6M/S,2025年SSR/Clash/V2ray/Shadowrocket每天更新免费机场订阅链接
- 宠物店猫粮品牌(宠物店里的猫粮是哪里批发的)
- 「1月25日」最高速度19.7M/S,2025年V2ray/SSR/Shadowrocket/Clash每天更新免费机场订阅链接
- 动物疫苗检测找哪个部门 动物疫苗检测找哪个部门负责
- 「2月3日」最高速度21.8M/S,2025年Clash/Shadowrocket/V2ray/SSR每天更新免费机场订阅链接
- 动物疫苗的重要性有哪些呢(动物疫苗的概念)
- 「1月15日」最高速度18.3M/S,2025年Clash/SSR/Shadowrocket/V2ray每天更新免费机场订阅链接
- 「3月1日」最高速度20.6M/S,2025年Shadowrocket/V2ray/Clash/SSR每天更新免费机场订阅链接