vue-axios的使用方法(简单易懂)

1.vue-axios插件的安装
使用 npm:

$ cnpm install axios

2.在main.js中添加(添加到原型链上)

import axios from 'axios';
Vue.prototype.axios = axios;

完活,然后就可以随便在任何组件开始用了,耶!^-^!

例子:

this.axios.post('http://ai.yiche.com/web/ability/nlu/standardTokenizer', {
                    "text": "动效如果有跟评审结论有出入的地方或者不清楚的地方,随时沟通哈~"
                }).then(function(res) {
                    console.log(res.data);
                }).catch(function(err) {
                    if (err.response) {
                        console.log(err.response)
                    }
                });

猜你喜欢

转载自blog.csdn.net/jingtian678/article/details/84933830