您的位置:首页 > 产品设计 > UI/UE

vue-resource数据交互

2018-01-17 14:24 591 查看
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/vue.js" ></script>
<script type="text/javascript" src="js/vue-resource.js" ></script>

<style>
#app{
width: 500px;
overflow: hidden;
border: 1px solid #ccc;
margin: 0 auto;
}
#app a{
display: block;
text-decoration: none;
border-bottom: 1px solid #E5E5E5;
color: #000;
width: 100%;
height: 100px;
}
.d_1{
width: 30%;
height: 100%;
display: inline-block;
float: left;
}
.d_1 img{
display: block;
width: 100%;
height: 100%;
}
.d_2{
width: 70%;
height: 100%;
float: left;
display: inline-block;
}
.d_2 span{
width: 100%;
display: inline-block;
}
</style>
</head>
<body>
<div id="app">
<a :href="value.url" v-for='value in myData'>
<div class="d_1">
<img :src='value.images' alt="无图"/>
</div>

<div class="d_2">
<span>{{value.desc}}</span>
<span>{{value.publishedAt | dateTime}}</span>
<span>{{value.who}}</span>
</div>

</a>
</div>
</body>

</html>

<script>
new Vue({
el:'#app',
data:{
myData:[

]
},
methods:{

},
filters:{
dateTime:function(value){
let oDate=new Date();
return oDate.getFullYear()+'/'+(oDate.getMonth()+1)+'/'+oDate.getDate()+' '+oDate.getHours()+':'+oDate.getMinutes()+':'+oDate.getSeconds();
}
},
created(){
this.
$http
.get('http://gank.io/api/data/Android/10/12').then(function(res){
this.myData=res.data.results
},function(res){
alert('2')
})
},
computed:{

}

})

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: