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>
<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>
相关文章推荐
- 使用vue-resource进行数据交互
- 数据交互vue-resource
- 使用vue-resource进行数据交互的实例
- 详解vue与后端数据交互(ajax):vue-resource
- vue与后端数据交互(ajax):vue-resource
- Vue - 请求json数据,前后端交互, vue.resource
- 使用vue-resource进行数据交互
- 详解vue-Resource(与后端数据交互)
- 详解vue前后台数据交互vue-resource文档
- vue-Resource(与后端数据交互)
- 使用vue-resource进行数据交互
- vue-Resource(与后端数据交互)
- vue-Resource(与后端数据交互)
- Vue2学习笔记之请求数据交互vue-resource
- Vue2学习笔记:数据交互vue-resource
- vue与后端数据交互(ajax):vue-resource
- [置顶] Vue2.0 之vue-resource 模拟服务端返回本地json数据
- vue.js前后端数据交互之提交数据操作详解
- Angular 学习系列 - - $resource 更高端的数据交互
- Vue-数据交互