Js determines whether pc or mobile load the corresponding code.

the vue project determines the route directly to the mobile terminal if the mobile terminal is redirected to the mobile terminal in router.beforeeach. Else is pc, so load the root route.
the problem now is that when the mobile terminal accesses, it will flash the home page of the pc first and then jump to the route of the mobile terminal. How to solve this. The desired result of
is that pc loads the pc home page directly. Move to load the mobile home page directly. The pc homepage will not flash first on the jump transfer mobile

Sep.03,2021

the front end loads js only after the html is loaded. At this time, the html is already loaded and then the jump will naturally flash. Let the backend do it or ng configure


it is recommended to do proxy distribution in the nginx/apache layer to determine the source of the device and distribute it to different pages for landing. Using beforeEach, as you said, cannot solve the problem of flash, which brings about problems in experience.

nginx configuration reference https://blog.csdn.net/u012562.


No. This depends on where the code written by your router.beforeeach is written in the program. The project I have done is also judged by router.beforeeach. If you write it before the new Vue loads the instance, the page will not go in at all, nor can you see the source code inside. Take a closer look at my https://github.com/markbzhang.

Menu