Home > Article > Backend Development > vue.js - How to traverse the json object returned by php with Vue?
1. I use ajax to request a piece of data from php, a two-dimensional array on the php side, and return it to the front-end ajax after json_encoding
2. After the front-end receives the data, how to use Vue to traverse it
<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>
1. I use ajax to request a piece of data from php, a two-dimensional array on the php side, and return it to the front-end ajax after json_encoding
2. After the front-end receives the data, how to use Vue to traverse it
<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>
You pointed to the wrong this
:src="{{ i.litpic | addpre }}"
filters: {
<code> addpre: function (val) { return 'http://www.baidu.com' + val } } </code>
{{ i.title }}
If the page is bound to v-model, just use v-for to loop the output
You can also use devtool to debug
https://github.com/vuejs/vue-...