vue处理json数据的原理_vue中json处理方法
json后端给我的数据,现在要将 标准陪练-5节 这条数据不展示。我的想法第一想法是要么隐藏,要么处理json删除这条数据。我用delete,但是发现原json长度不变只是变空了,而且在v-for渲染的时候报错了{{item.lesson_name}}var app = new Vue({el:"#myapp",data:function(){return{json:[{"type_name":"
json后端给我的数据,现在要将 标准陪练-5节 这条数据不展示。我的想法第一想法是要么隐藏,要么处理json删除这条数据。我用delete,但是发现原json长度不变只是变空了,而且在v-for渲染的时候报错了
{{item.lesson_name}}
var app = new Vue({
el:"#myapp",
data:function(){
return{
json:[
{"type_name":"正课","lesson_name":"标准陪练课(中级)-90节","course_name":"标准陪练","lesson_no":"BZ-c2-3","lesson_num":90,"lesson_id":37,"xufei_buy_num":1,"level_name":"中级","money":11380,"shengyu_lesson_num":100,"free_lesson_num":12,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:32:41","lesson_min":50,"shouci_buy_num":1},
{"type_name":"正课","lesson_name":"标准陪练课(中级)-120节","course_name":"标准陪练","lesson_no":"BZ-c2-4","lesson_num":120,"lesson_id":38,"xufei_buy_num":0,"level_name":"中级","money":14180,"shengyu_lesson_num":0,"free_lesson_num":0,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:33:38","lesson_min":50,"shouci_buy_num":0},
{"type_name":"正课","lesson_name":"标准陪练课(中级)-200节","course_name":"标准陪练","lesson_no":"BZ-c2-5","lesson_num":200,"lesson_id":39,"xufei_buy_num":0,"level_name":"中级","money":22880,"shengyu_lesson_num":217,"free_lesson_num":17,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:35:01","lesson_min":50,"shouci_buy_num":1},
{"type_name":"正课","lesson_name":"标准陪练课(高级)-30节","course_name":"标准陪练","lesson_no":"BZ-c3-1","lesson_num":30,"lesson_id":40,"xufei_buy_num":1,"level_name":"高级","money":4680,"shengyu_lesson_num":35,"free_lesson_num":10,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:36:20","lesson_min":50,"shouci_buy_num":0},
{"type_name":"正课","lesson_name":"标准陪练课(高级)-60节","course_name":"标准陪练","lesson_no":"BZ-c3-2","lesson_num":60,"lesson_id":41,"xufei_buy_num":1,"level_name":"高级","money":9180,"shengyu_lesson_num":58,"free_lesson_num":2,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:37:36","lesson_min":50,"shouci_buy_num":0},
{"type_name":"正课","lesson_name":"标准陪练课(高级)-90节","course_name":"标准陪练","lesson_no":"BZ-c3-3","lesson_num":90,"lesson_id":42,"xufei_buy_num":0,"level_name":"高级","money":13480,"shengyu_lesson_num":91,"free_lesson_num":3,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:38:41","lesson_min":50,"shouci_buy_num":1},
{"type_name":"正课","lesson_name":"标准陪练课(高级)-120节","course_name":"标准陪练","lesson_no":"BZ-c3-4","lesson_num":120,"lesson_id":43,"xufei_buy_num":0,"level_name":"高级","money":17080,"shengyu_lesson_num":0,"free_lesson_num":0,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:39:45","lesson_min":50,"shouci_buy_num":0},
{"type_name":"正课","lesson_name":"标准陪练课(高级)-200节","course_name":"标准陪练","lesson_no":"BZ-c3-5","lesson_num":200,"lesson_id":44,"xufei_buy_num":0,"level_name":"高级","money":27680,"shengyu_lesson_num":0,"free_lesson_num":0,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-10-16 13:40:58","lesson_min":50,"shouci_buy_num":0},
{"type_name":"正课","lesson_name":"标准陪练-20节","course_name":"标准陪练","lesson_no":"BZ-c0-02","lesson_num":20,"lesson_id":64,"xufei_buy_num":0,"level_name":"全级别","money":2000,"shengyu_lesson_num":0,"free_lesson_num":0,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-11-24 15:15:22","lesson_min":50,"shouci_buy_num":0},
{"type_name":"正课","lesson_name":"标准陪练-5节","course_name":"标准陪练","lesson_no":"BZ-c0-01","lesson_num":20,"lesson_id":63,"xufei_buy_num":0,"level_name":"全级别","money":2000,"shengyu_lesson_num":14,"free_lesson_num":0,"mode_name":"陪练","tuifei_num":0,"modify_date":"2017-11-24 15:14:44","lesson_min":25,"shouci_buy_num":1}
]
}
},
created:function(){
//解开就报错
// for (let i = 0; i < this.json.length; i++) {
// console.log(i)
// for(let k in this.json[i]){
// if (this.json[i][k] == "标准陪练-5节") {
// delete this.json[i];
// break;
// }
// }
// }
}
})
更多推荐
所有评论(0)