【问题标题】:Route parameter passing error : Laravel+Vue路由参数传递错误:Laravel+Vue
【发布时间】:2019-08-07 13:38:27
【问题描述】:

我正在使用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 进行测试时,找不到页面来了。此错误所需的原因。

【问题讨论】:

  • 路由器是否配置为使用历史模式?

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


【解决方案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', '.*');

【讨论】:

    猜你喜欢
    • 2018-06-20
    • 1970-01-01
    • 2020-06-13
    • 2018-02-13
    • 1970-01-01
    • 2018-06-20
    • 2017-01-13
    • 2019-03-03
    • 2018-08-14
    相关资源
    最近更新 更多