为checkout添加切换状态时添加回调函数
This commit is contained in:
parent
ec00075b4e
commit
c58c836b7c
5 changed files with 11 additions and 1 deletions
|
@ -191,6 +191,11 @@ export default class PluginSample extends Plugin {
|
|||
type: "checkbox",
|
||||
title: "Checkbox text",
|
||||
description: "Check description",
|
||||
checkbox: {
|
||||
callback: () => {
|
||||
console.log("Checkbox clicked");
|
||||
}
|
||||
}
|
||||
});
|
||||
this.settingUtils.addItem({
|
||||
key: "Select",
|
||||
|
|
3
src/libs/index.d.ts
vendored
3
src/libs/index.d.ts
vendored
|
@ -12,6 +12,9 @@ interface ISettingItem {
|
|||
step: number;
|
||||
};
|
||||
options?: { [key: string | number]: string };
|
||||
checkbox?: {
|
||||
callback: () => void;
|
||||
}
|
||||
button?: {
|
||||
label: string;
|
||||
callback: () => void;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{title}
|
||||
<div class="b3-label__text">
|
||||
{@html description}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="fn__space" />
|
||||
<!-- <slot /> -->
|
||||
|
|
|
@ -104,6 +104,7 @@ export class SettingUtils {
|
|||
element.checked = item.value;
|
||||
element.className = "b3-switch fn__flex-center";
|
||||
itemElement = element;
|
||||
element.onchange = item.checkbox?.callback ?? (() => { });
|
||||
break;
|
||||
case 'select':
|
||||
let selectElement: HTMLSelectElement = document.createElement('select');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue