封装带参数的函数

这里用的是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;
  });
};
posted @   zongkm  阅读(6)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示