安裝node
安裝 vue-cli
啟動
在vue中使用axios請求json數(shù)據(jù)
第一步:安裝axios
npm install axios --save // 使用axios發(fā)送請求
main.js文件中:
import axios from 'axios'; // 消息請求
Vue.prototype.$http = axios; // 將axios掛載到Vue實例中的$http 上面
第二步:安裝vue文件請求
this.$http.get('./api/home').then((res) => {
this.content = res.data;
console.log(this.content);
}).catch((err) => {
console.log(err);
});