Vue axios发送Http请求
1.cnpm install axios --save
2.在vue文件中引入,import Axios from 'axios'
3.使用,Axios.get(url).then((res)=>{}).catch((err)=>{})
<template><div id="app">
<div v-html="htmlValue"></div>
</div>
</template>
<script>
import Axios from "axios";
export default {
name: "app",
data() {
return {
flag: true,
htmlValue: ""
};
},
methods: {
getData() {
Axios.post(`http://api2.cpf360.com/api/auth/login`)
.then(res => {
console.log(res)
this.htmlValue=res.data
})
.catch(err => {});
}
},
mounted() {
this.getData();
}
};
</script>
<style lang="scss">
</style>
以上是 Vue axios发送Http请求 的全部内容, 来源链接: utcz.com/z/376535.html