当我单击路由器链接以转到注册表形式的页面时,URL会更改,但组件不会加载。
我有一个组件中的导航栏,我认为这是错误的,但没有...
以下是路由器的文件代码:
import {createRouter, createWebHashHistory} from 'vue-router'
const routes = [
{
path: '/',
name: 'Home',
component: () => import(/* webpackChunkName: "home" */ '../views/Home.vue')
},
{
path: '/formulario-registro',
name: 'RegisterForm',
component: () => import(/*webpackChunkName: "registerform"*/ '../views/RegisterForm.vue')
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
});
export default router
这是我的导航组件,其中有路由器链接:
<div class="nav">
<div class="brand">
<router-link to="/">BookArt</router-link>
</div>
<div class="collapse">
<span id="mobile-icon" v-on:click="responsiveNavbar"></span>
</div>
<div class="links">
<ul id="nav-list-group">
<li class="list-item">
<router-link to="/"> Inicio</router-link>
</li>
<li class="list-item">
<router-link to="/formulario-registro"> Registro</router-link>
</li>
<li class="list-item">
<router-link to=""> Login</router-link>
</li>
</ul>
</div>
我的main.js代码:
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
createApp(App).use(store).use(router).mount('#app')
和我的应用程序.vue代码:
<template>
<Nav></Nav>
<router-view/>
</template>
<script>
import Nav from '@/components/Nav.vue'
export default {
components: {
Nav
}
}
</script>
下面是我的寄存器窗体组件的代码:
<template>
<form action="">
<div class="form-group">
<input type="text" name="form.username" id="form.username" class="username" placeholder="Nombre de usuario....">
</div>
<div class="form-group">
<input type="file" name="form.profile_pic" id="form.profile_pic" class="profile_pic"
placeholder="Foto de perfil....">
</div>
<div class="form-group">
<input type="email" name="form.email" id="form.email" class="email" placeholder="Email....">
</div>
<div class="form-group">
<input type="password" name="form.password" id="form.password" class="password" placeholder="*******">
</div>
<div class="form-group">
<input type="password" name="form.confirm_password" id="form.confirm.password" class="confirm_password"
placeholder="*******">
</div>
<div class="form-group">
<button>Registrarse</button>
</div>
</form>
</template>
<script>
export default {
name: "Register-form",
mounted() {
console.log('Its ok');
}
}
</script>
2条答案
按热度按时间jchrr9hc1#
应用程序版本变更=〉
bvjxkvbb2#
问题出在
../view/RegisterForm
组件中,该组件呈现自身:这将生成一个无限循环,要解决此问题,只需更改导入组件的名称: