请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

2回答

璃音丶 2019-03-05 09:34:30

main.js中

import axios from 'axios'
Vue.prototype.$axios = axios
new Vue({   axios,   router,   store,   render: h => h(App)}).$mount('#app')


组件中使用

例:

this.$axios({
           method: 'get',
           url:'/index.json',
           data: {
                   city: this.city
               }
            }).then(this.getHomeInfoSuccess)


0 回复 有任何疑惑可以回复我~
  • Dell #1
    这种写法也ok
    回复 有任何疑惑可以回复我~ 2019-03-05 22:52:23
Dell 2019-03-04 20:58:48

你必须在每个用的地方引入,这是个模块,模块只在所在模块中有用

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号