前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >VUE数据绑定之axios数据请求 原

VUE数据绑定之axios数据请求 原

作者头像
晓歌
发布2018-08-15 14:58:17
4830
发布2018-08-15 14:58:17
举报
文章被收录于专栏:破晓之歌破晓之歌
代码语言:javascript
复制
<template>

            <div class="wl_venue_left">
                <ul>
                    <li v-for="(item, index) in venue" :key="item.index">
                        <a href="">
                            {{item.index}}
                            <div class="wl_venue_img"><img :src="item.img" alt=""><span>{{index+1}}</span></div>
                            <div class="wl_venue_txt">
                                <h2>{{item.name}}</h2>
                                <p>{{item.address}}</p>
                            </div>
                        </a>
                    </li>

                </ul>
                <Pages></Pages>
            </div>
</template>

<script>

export default {
  name: 'index',
  data () {
    return {
        venue:[]
    }
  },
   beforeCreate:function(){
   this.$ajax.get('http://localhost:8080/getdata')
    .then( (response) => {
    //     var datajson=[
    //   {id:'1',img: "the very first post", address: "1test dimpsum", name: "lorem1"},
    //   {id:'2',img: "and then there was the second", address: "2test dimsum",name: "lorem2"},
    //   {id:'3',img: "third time's a charm", address: "3test dimsum",name: "lorem3"},
    //   {id:'4',img: "four the last time", address: "4test dimsum",name: "lorem4"}
    // ]
    // 传入的json格式示例如上
    // const list = Object.keys(json).map((item, index) => ({key: item, value:json[item]}
        this.venue=response.data
        // this.venue.push(response.data)
        console.log(this.venue)
    })
    .catch(function (error) {
        console.log(error);
    });
  },
  mounted:function(){
      console.log(this.venue)
  },
  components: {
    'MySearch': MySearch
  }
}
</script>

<style scoped lang="scss">
</style>
代码语言:javascript
复制
import axios from 'axios'
Vue.prototype.$ajax = axios
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档