封装带参数的函数
这里用的是vue3
原来的写法不封装,直接卸载onBeforeMount内
onBeforeMount(() => {
getSecondCategorys({
pageNum: 1,
pageSize: 8
}).then((res) => {
secondList.value = res.data.list;
});
});
封装一层之后的写法,写在外面,引用的时候才写在onBeforeMount内
onBeforeMount(() => {
secondCategorys({
categoryId: -1,
});
const secondCategorys = (params) => {
getSecondCategorys(params).then((res) => {
secondList.value = res.data.list;
});
};

浙公网安备 33010602011771号