1.引入插件axios
<script src="./node_modules/axios/dist/axios.js"></script>
2.axios方法写在created函数体中
created() { axios.get('http://127.0.0.1:5500/db.json') .then(respons => this.axiosData = respons.data) }
3.完整版
created() { axios.get("http://127.0.0.1:5500/vue-01/db.json") .then((response)=>{ console.log(response.data); this.msg=response.data }) .catch((error)=>{ console.log(error.message); }) .finally(()=>{ console.log("finally") }) }
浙公网安备 33010602011771号