Vue
by zhouyulong
HTML
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.js"></script>
<div id="app">
<h2>Phone tree:</h2>
<ul>
<li v-for="item in phoneList">
<span>{{item.id}}</span>
<span>{{item.name}}</span>
</li>
</ul>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
Vue
new Vue({
el: "#app",
data: {
phoneList: []
},
mounted() {
axios.get('https://private-4f7c1-zyl1.apiary-mock.com/questions')
.then(response=> {
console.log(response);
this.phoneList = response.data;
})
.catch(error => {
console.log(error);
});
},
methods: {
}
})