中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
@LocalStorageLink和LocalStorage如何实现双向同步?
微信扫码分享
let para: Record<string, number> = { 'PropA': 47 }; let storage: LocalStorage = new LocalStorage(para); let linkToPropA: SubscribedAbstractProperty<object> = storage.link('PropA'); @Entry(storage) @Component struct CompA { @LocalStorageLink('PropA') storageLink: number = 1; build() { Column() { Text(`incr @LocalStorageLink variable`) .onClick(() => { this.storageLink += 1 }) Text(`@LocalStorageLink: ${this.storageLink} - linkToPropA: ${linkToPropA.get()}`) } } }