<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Vue js Axios</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="app">
<p>{{tasks.title}}</p>
</div>
<script>
var vm = new Vue ({
el:'#app',
data: {
tasks : ''
},
mounted(){
axios.get('https://api.myjson.com/bins/17x8qm')
.then(response => this.tasks = response.data);
}
});
</script>
</body>
</html>
http://blog.vuejoy.com/4-axios/
No comments:
Post a Comment