完全卸载和重新加载伪造查看器 [英] Completely unload and reload forge viewer
问题描述
我正在Angular 5应用程序上使用Forge Viewer.
I'm using the Forge Viewer on an Angular 5 application.
有没有一种方法可以完全卸载查看器,以便以后可以重新加载?
Is there a way to completely unload the viewer so it can later be reloaded?
我有以下代码来卸载查看器:
I have the following code to unload the viewer:
if (this.viewer && this.viewer.running) {
this.viewer.tearDown();
this.viewer.finish();
this.viewer = null;
}
我还具有每次用户进入页面时都加载查看器的代码.
And I also have the code to load the viewer every time the user enters the page.
当前,当用户导航到应用程序上的其他页面时,该代码将被执行,但是当用户返回到包含查看器的页面时,它将显示一个灰色框,显示查看器的位置.
Currently, when a user navigates to a different page on the application, that code gets executed, but when the user comes back to the page that contains the viewer, it shows a grey box where the viewer should be.
这是一个重现该问题的github存储库: https://github.com/theivanaguilar/forge-viewer-reload
Here's a github repo that reproduces the issue: https://github.com/theivanaguilar/forge-viewer-reload
我在这里想念东西吗?
推荐答案
静态方法Autodesk.Viewing.Initializer
只能在其后一次不返回的情况下调用一次.每次加载组件时,都需要调用所有其他查看器方法.因此,您需要稍微重构代码.
The static method Autodesk.Viewing.Initializer
can only be called once the subsequent times it will not return. All other viewer methods need to be invoked every time your component loads. So you need to refactor your code a bit.
My app is using React and I save a boolean in the appState to avoid calling that Initializer twice if it has been initialized already.
希望有帮助
这篇关于完全卸载和重新加载伪造查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!