路线参数传递错误:Laravel + Vue

时间:2019-03-16 18:25:40

标签: laravel laravel-5 vue.js routes laravel-5.7

我正在使用Laravel 5.7Vue.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中开始测试时, 找不到页面 即将到来。此错误所需的原因。

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', '.*');