vue 2.0 哪些不为人知的bug

1:    this.$router.query 递参数类型number,刷新后自动转成字符串

解决办法:类型强转

2:    Vue不能检测以下变动的数组

  1. 当使用索引直接改变或者设置一个项时,例如:this.items[index] = newvalue。
  2. 当修改数组的长度时,例如:this.items.lenght = newValue

解决办法:

第一类解决办法:

// Vue.set
this.$set(this.items, indexOfItem, newValue)

// Array.prototype.splice
this.items.splice(indexOfItem, 1, newValue)
复制代码

第二类解决办法:

vm.items.splice(newLength)

猜你喜欢

转载自blog.csdn.net/lianjiuxiao/article/details/113049964