feat: 汉字页输入和选择体验优化
This commit is contained in:
@@ -45,9 +45,23 @@ Component({
|
||||
},
|
||||
observers: {
|
||||
cardList(newVal: CardList) {
|
||||
if (!Array.isArray(newVal)) return;
|
||||
// 练字贴等页面只传 selectedWords、cardList 恒为 [],勿用空列表覆盖已选字
|
||||
if (newVal.length === 0) {
|
||||
const fromProp = this.properties.selectedWords as string[];
|
||||
if (Array.isArray(fromProp) && fromProp.length > 0) return;
|
||||
}
|
||||
const selectedWords = newVal.map((item) => item.word);
|
||||
this.setData({ selectedWords });
|
||||
},
|
||||
/** 仅在弹窗打开时从父组件同步一次,避免监听 selectedWords 与 setData 形成死循环 */
|
||||
show(show: boolean) {
|
||||
if (!show) return;
|
||||
const incoming = this.properties.selectedWords as string[];
|
||||
this.setData({
|
||||
selectedWords: Array.isArray(incoming) ? [...incoming] : [],
|
||||
});
|
||||
},
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
|
||||
Reference in New Issue
Block a user