Vue 函数传参优化

定义:

fetchSalesAreaBlock ({page = 0, pageSize = 10, areaId = '', areaName = ''} = {}) {
        let params = {
          area_id: areaId,
          area_name: areaName,
          page: page,
          size: pageSize
        }
        console.log('获取销售区域接口-参数', params)
        fetchSalesArea(params).then(res => {
          console.log('获取销售区域接口-数据', res)
          if (!res.data) return
          this.tableData = res.data.sale_area_dto_list
          this.total = res.data.total
          this.pageSize = res.data.page_size
        }).catch(err => {
          console.log('获取销售区域接口-报错', err)
        })
      },

传递:

this.fetchSalesAreaBlock({page: page})
this.fetchSalesAreaBlock({areaName: this.searchJson.area_name})

你可能感兴趣的:(Vue 函数传参优化)