【发布时间】:2019-06-17 22:38:01
【问题描述】:
我有包含类别、子类别和产品的树形导航。我需要为类别和产品定义两条路线。可以有多个嵌套的子类别。
我想展示相同的组件,例如/category 和 /category/subcategory/subcategory/subcategory 也是如此。
产品路线看起来像category/product/productslug 或category/subcategory/subcategory/subcategory/product/productslug,其中product 是特定产品标签之前的前缀。
在 Laravel 中我做了这样的事情:
对于产品:
Route::get('/{category?}/product/{slug}', 'ProductController@getProductBySlug')->where('category', '.*');
对于类别:
Route::get('/{category?}', 'CategoryController@getCategoryBySlug')->where('category', '.*');
在 Vue 路由器中不能像这样工作:
routes: [
{path: '/', component: HomeView},
{path: '*/product/:slugproduct', component: ProductView},
{path: '*', component: CategoryView},
]
【问题讨论】:
标签: vue.js vue-router