前情提要:axios 的使用vue
axios是一個ajax 的包,主要在node.js 使用node
axios 的官網ios
https://www.kancloud.cn/yunye/axios/234845ajax
一:書寫格式axios
二:在cli 中下載axios this
三: 在主程序mian.js中spa
四: 註冊使用的vuecdn
五:在home.vue 中使用axiso 文件blog
模板層ip
js層
<script>
export default {
name: "home",
data(){
return {
msg:'',
lable:''
}
},
created(){
this.$axios.get("http://wthrcdn.etouch.cn/weather_mini?city=深圳").then(response=>{
console.log(response.data);
console.log(response.data.data.ganmao);
this.lable = response.data.data.ganmao;
}).catch(error=>{
});
},
methods:{
ble(){
alert("123")
}
}
}
</script>
效果圖: