Heim  >  Artikel  >  Backend-Entwicklung  >  vue.js - php返回的json对象Vue怎么遍历?

vue.js - php返回的json对象Vue怎么遍历?

WBOY
WBOYOriginal
2016-10-17 09:30:021382Durchsuche

1.我使用ajax请求php一个数据, php端二维数组,json_encode后 返回给前端ajax
2.前端收到数据后,怎么使用Vue遍历

vue.js - php返回的json对象Vue怎么遍历?

<code>    
    new Vue({
        el:'#nav_vr',
        data:{
            list:null
        },
        methods:{
            showdata:function(id){
                alert(id);
                $.ajax({
                      type:"post",    //提交方法
                      url:"data.php",   //提交地址
                      data:{typeid:id},  //提交参数(可有可无)
                      dataType:"json", //响应结果的类型(可有可无)
                      success:function(d){ //接收响应结果
                          console.log(d);
                            this.list = d;
                      }
                });
            }
        }
    })</code>

vue.js - php返回的json对象Vue怎么遍历?

回复内容:

1.我使用ajax请求php一个数据, php端二维数组,json_encode后 返回给前端ajax
2.前端收到数据后,怎么使用Vue遍历

vue.js - php返回的json对象Vue怎么遍历?

<code>    
    new Vue({
        el:'#nav_vr',
        data:{
            list:null
        },
        methods:{
            showdata:function(id){
                alert(id);
                $.ajax({
                      type:"post",    //提交方法
                      url:"data.php",   //提交地址
                      data:{typeid:id},  //提交参数(可有可无)
                      dataType:"json", //响应结果的类型(可有可无)
                      success:function(d){ //接收响应结果
                          console.log(d);
                            this.list = d;
                      }
                });
            }
        }
    })</code>

vue.js - php返回的json对象Vue怎么遍历?

你的this 指错了

vue.js - php返回的json对象Vue怎么遍历?

:src=“{{ i.litpic | addpre }}”
filters: {

<code>        addpre: function (val) {
             return 'http://www.baidu.com' + val
        }
    }
</code>

{{ i.title }}

页面绑定 v-model 的话,使用 v-for 循环输出即可
还可以用devtool调试
https://github.com/vuejs/vue-...

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn