2 页面接口请求方式说明:

2 页面接口请求方式说明:

  示例:

  import { newLogin } from '@/api/index'

  newLogin(loginForm1)
    .then(res => {
        //相关逻辑
    })
    .catch(err => {
        //相关逻辑
    })
import { unitReportTemplate, isReportAdmin, getCurrentUser } from '@/api/law'

handleIndex() {
    //指标解释按钮方法
    unitReportTemplate(37) //返回指标解释报表详细信息
    .then(res => {
        if (res.status === 200 && res.data.status === 200) {
        this.indexIframeUrl = res.data.data.inputUrl + '&op=' + res.data.data.op
        } else {
        this.$message({ message: '数据加载失败,请刷新重试!', type: 'error' })
        }
    })
    .catch(err => {
        this.$message({ message: '失败,请刷新重试!', type: 'error' })
    })
}

@/api/law
//获取报表详细信息
export function unitReportTemplate (data) {
    return request({
        url: '/csp/report/getBaseReportInfo/'+data,
        method: 'get'
    })
}

没有这样用
vue中 dispatch( getInfo )
vuex中 actions: { const getInfo = 从@/api找方法 }
mutations 存到state里

应该是公共的方法,参数才在vuex中

posted @ 2022-03-10 16:55  波吉国王  阅读(37)  评论(0编辑  收藏  举报