//main.js
import Vue from "vue"
import App from "./App"
import router from "./router"
import axios from "axios"
Vue.config.productionTip = false;
Vue.prototype.$ajax = axios;
/* eslint-disable no-new */
new Vue({
el: "-sharpapp",
router,
components: { App },
template: "<App/>"
})
//HelloWorld
<script>
import "../mock/mock"
export default {
name: "HelloWorld",
data () {
return {
msg:"hello world",
data:[]
}
},
mounted:function () {
console.log(111);
this.getList()
},
methods:{
getList(){
this.$axios.get("/api/data").then((res)=>{
console.log(res);
})
}
}
}
</script>
//mock.js
import Mock from "mockjs"
//mockjs
Mock.mock("/api/data", (req, res) => {
return {
data: ["a","b"]
}
})
No matter how the consistent error is not defined ~ where is it not configured for advice? This article referenced by
https://codeshelper.com/a/11.