vue渲染数据失败

html部分
<ul id="shoucangLists">

            <template v-for="item in lists">
                <li class="shoucang_list no-edit" id="item.idNum">
                    <a href="" style="display:block;">
                        <div class="container o_hidden">
                            <u class="label lt"></u>
                            <div class="content gt o_hidden">
                                <div class="pic lt">
                                    <img :src="item.urlPic" alt=""/>
                                    <p>已下架</p>
                                </div>
                                <div class="text gt">
                                    <p>{{item.intro}}</p>
                                    <div class="o_hidden">
                                        <span class="lt">¥{{item.price}}</span>
                                        <s class="gt"></s>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </a>
                </li>
            </template>
        </ul>

js请求:
new Vue({

el:'#shoucangLists',
data:{
    lists:[]
},
created:function(){
    axios.get('js/data.json')
        .then(function(response){
            this.lists=response.data.shoucangLists;
        })
        .catch(function(error){
            console.log(error);
        });
}

})

页面完全没有数据显示,json数据显示已经加载,也没有报错。是哪里的问题呢?

阅读 2.5k
1 个回答
created:function(){
var _this = this
    axios.get('js/data.json')
        .then(function(response){
            _this .lists=response.data.shoucangLists;
        })
        .catch(function(error){
            console.log(error);
        });
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题