vue3+typescript,ref<number>作为参数传入函数时,实时响应失效,直接作为number类型传入
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
,
async control(process: ref<number>, array) {
for (let i = 0; i < array.length; i++) {
await this.sleep(75);
process = array[i];
console.log(this.process_value_1)
if (this.page_judge === false) {
process = 0
return null
}
}
process = 100
},
async start() {
this.page_judge = true
this.button_switch = 2
this.upload_switch = 1
if (this.page_judge) {
await this.control(this.process_value_1, this.process_1_array);
await this.control(this.process_value_2, this.process_2_array);
await this.control(this.process_value_3, this.process_3_array);
this.page_judge = false;
}
},
cancel() {
this.page_judge = false
this.process_value_1 = 0
this.process_value_2 = 0
this.process_value_3 = 0
this.upload_switch = 0
this.button_switch = 0
}
如果改为reactive的话,因为这样是对象,不对进行深拷贝,地址不变,但是要改很多代码,有没有类似于C++的参数的引用操作