第一种:路径传参

js:

// 下拉框数据
export function getUnits(userId,unitCode) {
  return request({
    url: `rfs/ledger/getUnits/${userId}/${unitCode}`,
    method: 'get'
  })
}

往vue组件页面导入js :

  import {
    getUnits,
    resourceSummaryByUnicode
  } from '@/api/resource/resource'

发送请求:

        getUnits(this.userId, this.unitCode).then((response) => {
          console.log(response.data.item)
          this.options = response.data.item
          this.loading = false
        })

第二种:定义params

js:

export function resourceSummaryByUnicode(params) {
  return request({
    url: `rfs/ledger/resourceSummaryByUnicode`,
    method: 'get',
    params
  })
}

往vue组件页面导入js :

  import {
    getUnits,
    resourceSummaryByUnicode
  } from '@/api/resource/resource'

定义请求方法:

      getSheet() {
        this.loading = true
        const val = {
          userId: this.userId,
          unitCode: this.unitCode
        }
        resourceSummaryByUnicode(val).then((response) => {
          console.log(response.data.item)
          this.List = response.data.item
          this.loading = false
        })
      },

Logo

前往低代码交流专区

更多推荐