"Nuxt - Page does not load properly after executing "yarn generate""
P粉670107661
P粉670107661 2023-08-26 11:45:49
0
1
459

I have a simple nuxt application with a page located under the following directory structure:

pages callback index.vue

This application was built using "universal" mode. My problem is that when I run the application locally (i.e. yarn dev) the callback page displays perfectly and works fine. However, when I run yarn generate and then serve the dist folder, the page has some slight visual errors. There are no console errors or network errors, but the display is somewhat patchy. The problem is: a specific icon (hamburger menu) doesn't load, and the dropdown/select component doesn't initialize properly and show its placeholder until clicked.

These are components that have been built and work fine elsewhere in the application, but on the generated page, they don't work.

I have devtools enabled on the build output and the only difference I am able to see between the version running locally and the generated version is that when I navigate to the callback route the generated output does not seem to receive the vue devtools "Active" flag in .

I thought this was weird and read about navigable links and hidden pages (since this page is not currently linked to from anywhere on the site) and tried many things but nothing worked. The closest I've come is to create a NuxtLink element on the homepage that links to the callback route. When I do this, after clicking the link, the page works as expected and the active flag is set in the routing tab of devtools. But if I navigate to it via the URL bar it doesn't work.

I have read the documentation of nuxt and vue router in detail but can't seem to find a solution to the problem.

P粉670107661
P粉670107661

reply all (1)
P粉464208937

yarn generateis used to deploy a static site while your target is set to universal. Runyarn buildandyarn startto deploy in universal mode.

See documentationhere.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!