vue3.0 vite 自定义的子组件竟然不会热更新

vite配置如下

export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, "src"),
            // 'App': './App.vue'
        },
    },
    server: {
        https: false, // 是否开启 https
        open: true, // 是否自动在浏览器打开
        port: 8888, // 端口号
        host: "localhost",
        hmr: true,
        },
    }
})

在页面引入了一个自己的子组件,每次重启项目的时候才会编译页面,平时不管怎么管,都不会编译自己的自定义组件,但是其它在vue-router里面引入过页面会编译。
更新问题:
现在测试是在router-view当中引入的子组件才会出现不会热更新的问题,在app.vue当中引入子组件会热更新。怀疑是vue路由导致的问题。
router配置如下

import {createRouter, createWebHashHistory, RouteRecordRaw} from 'vue-router';
import HomePage from '@/view/home/home.vue';
import Entrance from '@/view/entrance/entrance.vue';


const routes:Array<RouteRecordRaw> = [
    // //登录页
    // {
    //     path:'/login',
    //     name:'Login',
    //     component:Login
    // },
    {
        path: '/',
        name: 'entrance',
        component: Entrance,
        alias: '/entrance',
        meta: {
            title: '入口'
        },
        children:[
            {
                path: '/home',
                name: 'home',
                component: HomePage,
                alias: '/home',
                meta: {
                    title: '首页'
                }
            },
        ]
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes
});

export default router;
阅读 4.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题