美文网首页
vue 项目搭建

vue 项目搭建

作者: zy_Judy | 来源:发表于2019-11-01 10:12 被阅读0次

安装node

安装 vue-cli

启动

在vue中使用axios请求json数据

第一步:安装axios

npm install axios --save // 使用axios发送请求

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

相关文章

网友评论

      本文标题:vue 项目搭建

      本文链接:https://www.haomeiwen.com/subject/zghtbctx.html