我对Vue.js很陌生,并且正在创建包含一些文章的webapp。有什么方法可以设置静态(domain.com/login)和动态(domain.com/:category)路由?
export default new Router({
mode: "history",
routes: [
{
path: "/",
component: Home
},
{
path: "/:category",
component: () => import("./views/CategoryView.vue")
},
{
path: "/:category/:article",
component: () => import("./views/ArticleView.vue")
},
{
path: '/login',
component: () => import(".views/Login.vue")
}
]
});
我从数据库中获取了类别列表,因此我无法为每个类别硬编码路径,并且我希望它们在域之后紧随其后,而不是domain.com/category/:category的伪造路径。