🐛 fix: 模板提供的 button 的 click 事件不生效; close #31
This commit is contained in:
parent
2c45caf80f
commit
8daa01aedb
5 changed files with 30 additions and 8 deletions
|
@ -14,11 +14,16 @@
|
|||
max: number;
|
||||
step: number;
|
||||
} = { min: 0, max: 100, step: 1 }; // Use it if type is slider
|
||||
export let button: {
|
||||
label: string;
|
||||
callback: () => void;
|
||||
} = { label: settingValue, callback: () => {} }; // Use it if type is button
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function clicked() {
|
||||
dispatch("clicked");
|
||||
function click() {
|
||||
button?.callback();
|
||||
dispatch("click", { key: settingKey });
|
||||
}
|
||||
|
||||
function changed() {
|
||||
|
@ -66,9 +71,9 @@
|
|||
<button
|
||||
class="b3-button b3-button--outline fn__flex-center fn__size200"
|
||||
id={settingKey}
|
||||
on:click={clicked}
|
||||
on:click={click}
|
||||
>
|
||||
{settingValue}
|
||||
{button.label}
|
||||
</button>
|
||||
{:else if type === "select"}
|
||||
<!-- Dropdown select -->
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Author : frostime
|
||||
Date : 2023-07-01 19:23:50
|
||||
FilePath : /src/libs/setting-panel.svelte
|
||||
LastEditTime : 2023-11-28 21:45:10
|
||||
LastEditTime : 2024-04-27 16:46:49
|
||||
Description :
|
||||
-->
|
||||
<script lang="ts">
|
||||
|
@ -39,6 +39,7 @@
|
|||
placeholder={item?.placeholder}
|
||||
options={item?.options}
|
||||
slider={item?.slider}
|
||||
button={item?.button}
|
||||
on:click={onClick}
|
||||
on:changed={onChanged}
|
||||
/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @Author : frostime
|
||||
* @Date : 2023-12-17 18:28:19
|
||||
* @FilePath : /src/libs/setting-utils.ts
|
||||
* @LastEditTime : 2024-01-15 20:45:16
|
||||
* @LastEditTime : 2024-04-27 16:38:09
|
||||
* @Description :
|
||||
*/
|
||||
|
||||
|
@ -329,5 +329,4 @@ export class SettingUtils {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue