css样式在vue项目页面刷新后删除

pvcm50d1  于 2023-05-18  发布在  Vue.js
关注(0)|答案(1)|浏览(181)

当我第一次去这个链接的页眉页脚样式是好的-x1c 0d1x
但是当我刷新或重新加载页面时,样式就消失了。怎么解决这个问题?

下面是My router.js-

import { createWebHistory, createRouter } from "vue-router";
import Home from '../components/Home.vue';
import Organization from '../components/aboutus/Organization.vue';

const router = createRouter({
    history: createWebHistory(),
    base: process.env.BASE_URL,
    scrollBehavior() {
        return { x: 0, y: 0 }
    },
    routes: [
        {
            name:'Home',
            path:'/',
            component:Home
        },
        {
            name:'Organization',
            path:'/about_us/organization',
            component:Organization
        },
    ],
})
router.beforeEach((to, _, next) => {

    return next()
})
// ? For splash screen
// Remove afterEach hook if you are not using splash screen
router.afterEach(() => {
    // Remove initial loading
    /*const appLoading = document.getElementById('loading-bg')
    if (appLoading) {
        appLoading.style.display = 'none'
    }*/
})
export default router

下面是主要的.js-

import { createApp } from 'vue'
import App from './App.vue'
import router from './router/router'
import store from './store/index'

createApp(App).use(
    router,
    store,).mount('#app')
z4bn682m

z4bn682m1#

在我的情况下,我改变了

<link rel="stylesheet" href="vendors/bootstrap/dist/css/bootstrap.min.css">

<link rel="stylesheet" href="/vendors/bootstrap/dist/css/bootstrap.min.css">

有css和javascript文件的确切地址,它的工作!
所有css和javascript文件都导入index.html

相关问题