码迷,mamicode.com
首页 > 移动开发 > 详细

vuebase--8._axios

时间:2019-08-11 09:16:15      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:get   vue   div   ted   css   display   ios   log   err   

_axios:

vue----->axios(网络请求)

Axios是一个基于promise的HTTP库,可以用在浏览器和node.js中。

安装

 npm install axios --save

引入:

import axios from ‘axios‘

Vue.prototype.$axios=Axios

实例:

<template lang="html">
<div class="hello">
HelloWorld!
</div>
</template>

<script>
export default {
name: ‘HelloWorld‘,
data() {
return {
msg: ‘Welcome to Your Vue.js App‘
}
},
mounted() {
this.$axios.get("xxxx")
.then(res => {
console.log(res.data)
}).catch(error => {
console.log(error);
})
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
font-weight: normal;
}

ul {
list-style-type: none;
padding: 0;
}

li {
display: inline-block;
margin: 0 10px;
}

a {
color: #42b983;
}
</style>

vuebase--8._axios

标签:get   vue   div   ted   css   display   ios   log   err   

原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11333619.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!