Merge pull request #30 from tengfei-xy/main

修改take()方法的获取方式
This commit is contained in:
Frostime 2024-04-25 21:31:11 +08:00 committed by GitHub
commit 2c45caf80f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 9 deletions

View file

@ -246,11 +246,9 @@ export default class PluginSample extends Plugin {
step: 1,
},
action:{
// The callback is called after the action of Silder changes,
// so it should be the this.settingUtils.get() method.
callback: () => {
// Read data in real time
let value = this.settingUtils.get("Slider")
let value = this.settingUtils.take("Slider")
console.log(value);
}
}

View file

@ -80,12 +80,12 @@ export class SettingUtils {
* @returns value in html
*/
take(key: string) {
let item = this.getElement(key)
this.settings.set(key, item)
if (item.type === 'button') {
return item.value
let element = this.elements.get(key) as any;
if (!element){
return
}
return item.value
this.settings.set(key, element.value)
return element.value
}
/**
@ -329,5 +329,5 @@ export class SettingUtils {
break;
}
}
}