Skip to content

Commit

Permalink
fix: 1.createEl异步创建,onNodeInserted回调中才能get到该元素
Browse files Browse the repository at this point in the history
  • Loading branch information
JuckZ committed Mar 3, 2023
1 parent 8939289 commit 9f4fa80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/ui/LineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ onMounted(async () => {
intersect: false,
},
};
// TODO Bug 通过document.getElementById无法获取元素
// Logger.log(document.getElementById('awesome-brain-manager-pomodoro-history-view'));
chart = new Chart(lineChart.value as unknown as ChartItem, {
type: 'line',
options: options,
Expand Down
13 changes: 7 additions & 6 deletions src/ui/view/PomodoroHistoryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export class PomodoroHistoryView extends ItemView {
}

async onOpen(): Promise<void> {
const container = this.containerEl.children[1];
container.empty();
container.createEl(
this.containerEl.empty();
this.containerEl.createEl(
'div',
{
cls: 'my-plugin-view',
Expand All @@ -42,10 +41,12 @@ export class PomodoroHistoryView extends ItemView {
},
},
el => {
this.vueapp = createApp(PomodoroHistory, {
plugin: this.plugin,
el.onNodeInserted(() => {
this.vueapp = createApp(PomodoroHistory, {
plugin: this.plugin,
});
this.vueapp.mount(el);
});
this.vueapp.mount(el);
},
);
}
Expand Down

0 comments on commit 9f4fa80

Please sign in to comment.