mirror of
https://github.com/siyuan-note/plugin-sample-vite-svelte.git
synced 2025-08-01 16:13:30 +00:00
Must destroy svelte
This commit is contained in:
parent
925d5c5aac
commit
aba6dfd544
3 changed files with 59 additions and 11 deletions
22
src/index.ts
22
src/index.ts
|
@ -9,6 +9,10 @@ import "./index.scss";
|
|||
|
||||
export default class SamplePlugin extends Plugin {
|
||||
|
||||
counter: { [key: string]: number } = {
|
||||
hello: 0,
|
||||
};
|
||||
|
||||
async onload() {
|
||||
console.log("onload");
|
||||
showMessage("Hello World");
|
||||
|
@ -25,22 +29,32 @@ export default class SamplePlugin extends Plugin {
|
|||
let dialog = new Dialog({
|
||||
title: "SettingPannel",
|
||||
content: `<div id="SettingPanel"></div>`,
|
||||
width: "600px"
|
||||
width: "600px",
|
||||
destroyCallback: (options) => {
|
||||
console.log("destroyCallback", options);
|
||||
//You must destroy the component when the dialog is closed
|
||||
pannel.$destroy();
|
||||
}
|
||||
});
|
||||
new SettingPannel({
|
||||
let pannel = new SettingPannel({
|
||||
target: dialog.element.querySelector("#SettingPanel"),
|
||||
});
|
||||
}
|
||||
|
||||
private openHelloDialog() {
|
||||
this.counter.hello++;
|
||||
let dialog = new Dialog({
|
||||
title: "Hello World",
|
||||
content: `<div id="helloPanel"></div>`,
|
||||
destroyCallback(options) {
|
||||
//You must destroy the component when the dialog is closed
|
||||
hello.$destroy();
|
||||
},
|
||||
});
|
||||
new Hello({
|
||||
let hello = new Hello({
|
||||
target: dialog.element.querySelector("#helloPanel"),
|
||||
props: {
|
||||
name: this.i18n.name,
|
||||
name: `[${this.counter.hello}]${this.i18n.name}`,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue