账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue-resource怎么抽象在接口中使用?
    54
    0

    Thank You For Your Time!

    我想将接口都模块化出来

    index-page.vue

    import {
        getCarList
    } from 'api/car.js';
    
    
    created: function () {
        getCarList();
    },

    car.js

    export function getCarList() {
        let url = domain + '/api/webOldCar/initNominate.action';
        this.$http.get(url).then((res) => {
            console.log(res);
        })
    }

    报错说this没有定义。我不知道在car.js中,this指向的是什么?也许是vue-resource?


    Thanks for your help!

    2
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部