Json获取
// Json 获取
new Vue({
el: '#get-users',
data: {
users: []
},
created() {
fetch('http://localhost:8080/users')
.then(response => response.json())
.then(json => {
this.users = json.data
})
}
})
Get方法
new Vue({
el: '#test-get',
data() {
return {
getinfo: null
}
},
mounted() {
axios
.get('http://localhost:8080/users')
.then(response => (this.getinfo = response))
.catch(function (error) {
// 请求失败处理
console.log(error);
});
}
})
Post方法
new