Asked the front twenty-three (20,190,923)

1, js how to obtain the key array

function getObjectKeys(object){
    var keys = [];
    for (var property in object)
    return property;
}

console.log(getObjectKeys(3332:[]))     // 3332

2, how to filter array null data

Array.prototype.notempty = function() {
  var arr = [];
  this.map(function(val, index) {
    if (val !== "" && val != undefined) {
      arr.push(val);
    }
  });
  return arr;
}
this.selectHouse = this.selectHouse.notempty()

3, iview after checkboxGroup delete a dynamic value, page checkBox selected disorder.

Details are as follows:

demand:

checkboxGroup v-for generating three checkbox, default check. When I click on a checkbox and delete the default uncheck the checkbox.

Method one:

From the last one to delete, delete the last value is the default binding array model in which time the remaining selected checkbox is normal.

Operating Method two:

But if deleted from the middle, such as deleting the second, then the second checkbox will be deleted, but the third checkbox is checked there is no style, model or in the data.

Solution one:

After we delete the model data, update data data update with this. $ NextTick

Solution two:

v-for when the key value does not take the index value and the actual value takes

extend:

when the v-for-rendered elements in the update list, using in situ reuse strategy, if the list of data changes, then it will take to determine whether to modify the value based on key values, if you modify the re-render this one, otherwise the complex data before use. But if we use the index as a key index, so in the example above, we removed the second data, data from the three became two, the list of re-rendering, while the third had a checkbox key is 2, Since the length of the data model into a 3 2. The third checkbox is composed of two key becomes a cause reassigned rendering. So exist led to the actual value, but missing disappeared selected issues.

Public concern small number [students] yao

No small public tender classmates

Guess you like

Origin www.cnblogs.com/lieone/p/11573036.html