【发布时间】:2021-12-11 09:54:01
【问题描述】:
// main.js
const app = createApp(App);
app.provide('$axios', axios);
window.renderSomething = function() {
app.mount('#ticker-maintenance-host');
}
该应用程序是使用 vuejs 和 blarzor 开发的。在 blazor 中,会调用它
@inject IJSRuntime JS;
@code{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JS.InvokeVoidAsync("renderSomething");
}
}
}
@page "/dashboard/page1"
<div id="ticker-maintenance-host"></div>
首先打开这个页面1,所有的内容都可以显示出来。如果我离开它并返回此页面,则没有任何显示。有个警告说
"[Vue warn]: App has already been mounted.
If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. `const createMyApp = () => createApp(App)`".
如何解决此警告并让我的内容在返回时显示而不刷新。
谢谢
【问题讨论】: