How do I add loading and failure states to an asynchronous routing component? #1696
-
What problem does this feature solve?After using routing asynchronous components, in the case of poor network, I had to wait for the network to load after clicking navigation. There was no feedback during this period, so I used defineAsyncComponent to wrap the component to provide standby Loading component when loading waiting and error display component when errors occurred. It works fine, but this approach comes with a strange caveat, I looked at the documentation and previous issues but didn't get a clear reason, and didn't get a better alternative to defineAsyncComponent from any of the answers What does the proposed API look like?I think the defineAsyncComponent usage warning should be removed if there is no better way to provide the Loading state and error state of the asynchronous Loading process. Of course the ultimate goal is not to remove the warning, but to have a solution to the loading and error feedback of the asynchronous component |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The question is simply closed, right? However, I have searched a lot of related problems, but there is no better solution, but I still keep warning in the project. Is it a good practice? |
Beta Was this translation helpful? Give feedback.
-
The router provides different hooks into the navigation process: beforeEach, afterEach, and onError should provide the information you need. |
Beta Was this translation helpful? Give feedback.
The router provides different hooks into the navigation process: beforeEach, afterEach, and onError should provide the information you need.