可以尝试使用toReftoRefs将响应式对象中的属性转换为响应式引用,然后通过修改引用的值来实现响应式更新。修改后的代码如下:

export interface GlobalConfigure { SetTop: boolean // 设置置顶 RemoveSource: boolean // 移除源件 RemoveRestore: boolean // 移除还原 AutomaticStartUp: boolean // 开机自启动 [key: string]: boolean; // 接受任何字符串密钥的索引签名 }

const globalConfigure: GlobalConfigure = reactive({ SetTop: false, // 设置置顶 AutomaticStartUp: false, // 开机自启动 RemoveSource: false, // 移除源件 RemoveRestore: true, // 移除还原 })

const refs = toRefs(globalConfigure)

Object.keys(refs).forEach((key) => { // 匹配是否为需要更新key if (changeAttribute === key) { // 重置更新值 refs[key].value = change } }

vue3 ts 这样设置值没有响应式 export interface GlobalConfigure SetTop boolean 设置置顶 RemoveSource boolean 移除源件 RemoveRestore boolean 移除还原 AutomaticStartUp boolean 开机自启动 key str

原文地址: https://www.cveoy.top/t/topic/eiRT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录