我得到了一個充滿 Vue.component 實例的 components.js。然后我得到了一個 main.js,其中有一個路由器,我正在使用這些組件來創(chuàng)建不同的頁面。在 index.html 我有路由器頁面的鏈接。問題是第一個頁面加載它沒有加載模板。如果我點擊主頁鏈接,什么也不會發(fā)生。但是,如果我單擊“關(guān)于”或“項目”,頁面將完全重新加載。(得到一個帶提示的 iframe,它再次顯示。)然后,單擊關(guān)于或項目后,一切正常。我嘗試在新選項卡中手動打開 example.com/#/,但它是一樣的。main.js 就像:const About = { template: '<div>About</div>' } const Home = { template: ` <web-header></web-header> ` }const Project = { template: '<div>Project</div>' } const routes = [ { path: '/', component: Home }, { path: '/about', component: About }, { path: '/projects', component: Project }] const router = new VueRouter({ routes: routes }) const app = new Vue({ router}).$mount("#app");
為什么 Vue Router 在我單擊鏈接之前不加載并在之后重新加載所有網(wǎng)頁
人到中年有點甜
2022-12-18 19:00:09