.keys 返回一个所有元素为字符串的数组,其元素来自于从给定的 上面可直接枚举的属性。这些属性的顺序与手动遍历该对象属性时的一致。

// simple array
var arr = ['a', 'b', 'c'];
console.log( .keys(arr)); // console: ['0', '1', '2']

// array like  
var obj = { 0: 'a', 1: 'b', 2: 'c' };
console.log( .keys(obj)); // console: ['0', '1', '2']

// array like   with random key ordering
var anObj = { 100: 'a', 2: 'b', 7: 'c' };
console.log( .keys(anObj)); // console: ['2', '7', '100']

// getFoo is a property which isn't enumerable
var myObj =  .create({}, {
  getFoo: {
    value: function () { return this.foo; }
  } 
});
myObj.foo = 1;
console.log( .keys(myObj)); // console: ['foo']

//-------------------------------表单清空

.keys(this.formValue).forEach((key) => {
  this.formValue[key] = null
})

 

注:在vue中

this.$refs[formName].resetFields(); //要配合prop才能用

收藏 打印