我刚刚完成开发并在Firebase https://newproject-dang.web.app/上部署了我的第一个SPA Vuejs应用程序。 通过在localhost上运行该应用程序,一切正常,我可以直接在URL上键入其他组件,但它不能在Firebase上运行,就像在搜索栏上键入此命令不起作用https://newproject-dang.web.app/calcul,它只能通过从导航栏,
vue路由器index.js
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Meteo from '../views/Meteo.vue'
import Calcul from '../views/Calcul.vue'
import Todo from '../views/Todo.vue'
import Sort from '../views/Sort.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/meteo',
name: 'Meteo',
component: Meteo
},
{
path: '/calcul',
name: 'Calcul',
component: Calcul
},
{
path: '/todo',
name: 'Todo',
component: Todo
},
{
path: '/sort',
name: 'Sort',
component: Sort
},
{
path: '*',
component: Home
}
]
const router = new VueRouter({
mode: "history",
routes
})
export default router
导航栏链接
<div class="links">
<ul>
<li @click="toggle()"><router-link to="/meteo" >Méteo</router-link></li>
<li @click="toggle()"><router-link to="/calcul" >Calculatrice</router-link></li>
<li @click="toggle()"><router-link to="/todo" >To-Do</router-link></li>
<li @click="toggle()"><router-link to="/sort" >Sort</router-link></li>
</ul>
</div>
firebase.json
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}