How is vue-resource abstractly used in interfaces?

< H2 > Thank You For Your time! < / H2 >

I want to modularize all the interfaces

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);
    })
}

error report that this is not defined. I don"t know what this points to in car.js. Maybe it"s vue-resource?.

< hr >

Thanks for your help!

Mar.30,2021

in the method of vue, the call to this.$http,this points to the vue component. Methods that are not internal to the vue component are called in the vue method, and the this cannot point to the vue component itself. There are several ideas:

car.js is rewritten like this

import axios from 'axios'

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

getCarList method is placed in the method inside the vue component

import {
    getCarList
} from 'api/car.js';


created: function () {
    this.getCarList();
},
methods: {
    getCarList: getCarList
}

the above two methods

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32e8b-403dc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32e8b-403dc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?