我正在使用Laravel 5.7
和Vue.js 2
。
我想测试Vue.js路由参数。但这不起作用!
app.js :
import ProductDetails from './components/front/shop/ProductDetails'
const routes = [
{
path: '/pds/:id',
component: ProductDetails
}
ProductDetails.vue
<template>
<h1>Book {{ $route.params.id }} </h1>
</template>
当我在localhost:8000/pds/1
中开始测试时, 找不到页面 即将到来。此错误所需的原因。
答案 0 :(得分:1)
您必须配置后端。参见here
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/{any}', 'SpaController@index')->where('any', '.*');