json 键值对增加、删除
obj.key='value';
// obj.key=obj[key]=eval("obj."+key); delete obj.key;
vue中新增和删除属性
this.$set(object,key,value)
this.$delete( object, key )
触发视图更新
遍历键值
for (var key in data) {console.log(key+':'+data[key]); //键:值
}
//Vue 中遍历
{ {key}} , { {value}} , { {index}}
{ {$key}} ,{ {value}} , { {$index}}
获取键值对个数
Object.keys(titleList).length
删除数组中指定元素
var objArray = [‘1’,’2’,’3’,’4’];
objArray.remove(‘1’);
/*定义js数组删除元素*/
Array.prototype.remove = function(val) {var index = this.indexOf(val);if (index > -1) {this.splice(index, 1);}
};