 |
|
standbill
V2EX member #229613, joined on 2017-05-08 09:05:32 +08:00
|
standbill's recent replies
是啊。
vue 的 vetur 出问题了。
主要原因是 vscode 更新太快,但是周边的插件更新不频繁。
有些是周边插件更新太快,vscode 本身还没反应过来。
需要做递归组件。最内层的 选框有初始值 v。
大概就是这样。
checked:{
get(){
if(this.children&&this.children.length>0){
return this.children.filter(v=v.checked).length === this.children.length
} else {
return this.v
}
// 或者 every 也行。
}
set(value){
//
if(this.children&&this.children.length>0) {
this.children.forEach(v=>{
v.checked = value
})
} else {
// 最内层了
this.v = value
}
}
}
其他方法也有。
手动写递归赋值什么的,不依靠依赖收集。
还可以用 store 的 getters 返回函数,进行计算属性的依赖收集。
手机端滑动,有 touch 事件。电脑端有 mousedown mouseup。
getconputedStyle,可以获得计算属性。