axios
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>
原文地址:https://www.cnblogs.com/chenyishi/p/9160776.html
时间: 2024-10-29 18:43:32