After the vue-cli is packaged, the resources are loaded normally, but the components are not loaded. What is the reason?

(resolved) the path of the app file output by the server corresponds to the one-to-one correspondence in the vuerouter configuration

after the vue-cli is packaged, the js of the page can see that the content is returned in the console, and the page does not report any errors, but the component is not loaded to achieve the effect. What is the reason?
the pages returned on the server are also available (look down to the picture, there is a static html of app.vue)

I really have no tricks to use. Ask for advice

ps: searched a bunch of config/index.js, that said to change webpack "/" change to ". /" I also changed it, and the effect of the package was the same. Some people said that mode: "history" was commented out, and I also commented it out. The package is still the same. What"s the situation? Be in a state of ignorance.








Apr.03,2021

Thank you for inviting ~
I don't understand what you said about not loading components. What components are not loaded?
how did you introduce or load this component.
dynamic introduction?
or introduce it directly?
or other ways?


because there is no error, I guess it is probably a path problem. Finally, I bet on the path and try to change the base: "path" under router/router.js to the same as the output path of the server.
the output from the server is http://localhost:3000/admin/main.html(, which is the content of app), and enter / admin/main.html


in the corresponding base option.

I also encounter this kind of problem. To sum up, all three didn't work. Finally, the app did not hang up after build because mode processing was added to the route.

clipboard.png
clipboard.png
clipboard.png
clipboard.png


Thank you for the invitation. Take a look at the problem first.
just finished looking at the problem, and then copied a new project to test. It does not reproduce what you said.
the following is router.js

import Vue from 'vue'
import Router from 'vue-router'

const index = () => import(/* webpackChunkName: "group-index" */ '@/page/index.vue')
// import index from '@/page/index.vue'
import home from '@/page/home.vue'
import proof_company from '@/page/proof_company.vue'
import proof_huji from '@/page/proof_huji.vue'
import proof_salary from '@/page/proof_salary.vue'
import printSettings from '@/page/printSettings.vue'
import printProgress from '@/page/printProgress.vue'
import makeCard from '@/page/makeCard.vue'
import rate from '@/page/rate.vue'
import admin from '@/page/admin.vue'
Vue.use(Router)

export default new Router({
  routes: [{
      path: '/',
      redirect: '/index'
    },
    {
      path: '/index',
      component: index
    },
    {
      path: '/admin',
      component: admin
    },
    {
      path: '/home',
      component: home,
      children: [{
          path: 'proof_company',
          component: proof_company,
        },
        {
          path: 'proof_huji',
          component: proof_huji,
        },
        {
          path: 'proof_salary',
          component: proof_salary,
        },
        {
          path: 'printSettings',
          component: printSettings,
        },
        {
          path: 'printProgress',
          component: printProgress,
        },
        {
          path: 'makeCard',
          component: makeCard,
        },
        {
          path: 'rate',
          component: rate,
        }
      ]
    }
  ]
})

the following is the build part of config/index.js

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',

    /**
     * Source Maps
     */

    productionSourceMap: true,
    // https://webpack.js.org/configuration/devtool/-sharpproduction
    devtool: '-sharpsource-map',

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }
}

the following is the index.vue section

<style lang="less" scoped>
.csot_wrapper {
  width:900px;
  height:600px;
  background-color: pink;
}
</style>
<template>
  <div class="csot_wrapper">
    test words
  </div>
</template>
<script>
export default {
  //props:{
    //props:{
      //type:String,
      //default:String,
    //},
  //},
  //data () {
    //return {
    //}
  //},
  //methods:{
    //example(){
      ////dosth
    //},
  //},
  //computed:{
    //computedA(){
      //return xxx
    //},
  //},
  //watch:{
    //watchA(val,oldval){//data||propskey,
      ////dosth
    //},
    //watchB:{//data||propskey,obj
      //deep:true,
      //handler(val,oldval){
        ////dosth
      //}
    //},
  //},
  created () {
    console.log('index.vue created' +  +new Date())
  },
  //mounted () {
  //},
  //beforeDestroy () {
  //},
  //beforeRouteEnter(to, from, next) {
    //next(vm => {
      ////  `vm` 
    //});
  //},
  //beforeRouteLeave(to, from, next){
    //// dosth this
    //next();
   //},
}
</script>

. Well, it's on the official website. I went to see my dependence

.

 Babel syntax-dynamic-import  Babel 
    "babel-plugin-syntax-jsx": "^6.18.0"
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32ba9-2be20.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32ba9-2be20.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?