(1)npm install --save axios vue-axios (2)import Vue from 'vue' 如上,先安装npm,然后引入3个文件就可以了。下面是个例子 <template> <div class="app-container"> <el-button type="text" @click="ee();">文字按钮</el-button> </div> </template> <script> import Vue from 'vue' import axios from 'axios' import VueAxios from 'vue-axios' export default { methods: { ee() { axios({ url: "http://rap2api./app/mock/121145/post", method: "post", data: { name: "小月", }, }).then((res) => { console.log("请求结果:", res); }); }, }, }; </script> |
|