Vue.js 什么会影响Vue计算属性的重新计算或否?

Vue.js 什么会影响Vue计算属性的重新计算或否?,vue.js,vue-component,vue-property-decorator,Vue.js,Vue Component,Vue Property Decorator,我希望每次更改selectedoptions索引时,currentSelectionViewContent都会重新计算。真的,有时它有效,有时-不 从“Vue属性装饰器”导入{Component,Prop,Vue,Watch}; @组成部分({ 模板 }) 导出类SelectField扩展Vue{ private onNewOptionSelected(新选项:SelectField.Option,索引INDEXINARRY:number):无效{ console.log(“~~~~~~~~~~

我希望每次更改
selectedoptions索引时,
currentSelectionViewContent
都会重新计算。真的,有时它有效,有时-不

从“Vue属性装饰器”导入{Component,Prop,Vue,Watch};
@组成部分({
模板
})
导出类SelectField扩展Vue{
private onNewOptionSelected(新选项:SelectField.Option,索引INDEXINARRY:number):无效{
console.log(“~~~~~~~~~~~~~~~~”;
log(JSON.stringify(this.selectedoptionindex,null,2));
此.selectedOptionsIndexes[0]=indexInArray;
log(JSON.stringify(this.selectedoptionindex,null,2));
console.log(“--------------”;
if(未定义(newOption.key)){
这是.$emit(“更改”,newOption.relatedEntity);
}否则{
这是.$emit(“更改”,newOption.key);
}
}
//“Vue属性装饰器”语法中的Vue计算属性
私有get-currentSelectionViewContent():字符串{
console.log(“重新计算…”);
开关(this.selectedoptions index.length){
案例0:
返回SelectField.DEFAULT\u NOTHING\u SELECTED\u占位符;
案例1:
返回此.selectOptions[this.selectedOptions索引[0]].title;
违约:
返回SelectField.DEFAULT\u多个选项\u所选\u字母;
}
}
}
工作案例:

非工作情况(无重新计算):


很抱歉,没有为这种情况创建复制(该问题导致的组件的复制、它的依赖关系以及环境)花费太长时间。如果您无法理解这里的错误,请告诉我什么会影响Vue computed属性重新计算或否。

Vue在阵列周围有某些行为需要注意。发件人:

Vue无法检测阵列的以下更改:

  • 当您直接使用索引设置项目时,例如。 vm.items[indexOfItem]=newValue
  • 当您修改 数组,例如vm.items.length=newLength
要确保Vue看到阵列的更改,请始终复制阵列并重新分配,如下所示:

var updatedIndexes = [...this.selectedOptionsIndexes]; // Copies array
updatedIndexes[0] = indexInArray; // Update the copy
this.selectedOptionsIndexes = updatedIndexes; // Overwrite with copy

谢谢你的回答!