我是Vue的新手,有一些nodejs后端经验。我遇到了问题,不断得到一个错误:
“Uncaught TypeError:VueRouter is not a constructor”.这是我的代码(app.js):
const routes=[
{ path:'/home', component: home },
{ path:'/zaposlenik', component: zaposlenik },
{path:'/department', component: department }
]
const route = new VueRouter({
routes
})
const app= new Vue({
router
}).$mount('#app')
字符串
我的department.js看起来像:
const department={template: '<h1>Ovo je odsjek</h1>'}
型
当然,我还有这个:
<nav class="navbar navbar-expand-sm bg-light navbar-dark">
<ul class="navbar-nav">
<li class="nav-item m-1">
<router-link class="btn btn-light btn-outline-primary" to="/home">Home</router-link>
</li>
<li class="nav-item m-1">
<router-link class="btn btn-light btn-outline-primary" to="/department">Odjel</router-link>
</li>
<li class="nav-item m-1">
<router-link class="btn btn-light btn-outline-primary" to="/zaposlenik">Zaposlenik</router-link>
</li>
</ul>
</nav>
<router-view></router-view>
</div>
<script src="variables.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.26.0/axios.min.js"></script>
<script src="https://unpkg.com/vue@3"></script>
<script src="https://unpkg.com/vue-router@4"></script>
<script src="home.js"></script>
<script src="department.js"></script>
<script src="zaposlenik.js"></script>
<script src="app.js"></script>
型
你能帮帮我吗?
先谢谢你了,
Vinko
1条答案
按热度按时间laawzig21#
字符串
这就对了!来自文档:入门