laravel - 路由参数传递错误:Laravel+Vue
问题描述
我正在使用Laravel 5.7
和Vue.js 2
。
我想测试 Vue.js 路由参数。但它不工作!
应用程序.js:
import ProductDetails from './components/front/shop/ProductDetails'
const routes = [
{
path: '/pds/:id',
component: ProductDetails
}
产品详情.vue
<template>
<h1>Book {{ $route.params.id }} </h1>
</template>
当我开始在localhost:8000/pds/1
Page not Found中进行测试时,即将到来。此错误所需的原因。
解决方案
您必须配置您的后端。看这里
<?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', '.*');
推荐阅读
- preg-match-all - preg_match_all 用结束词解析问题
- .net - 从 Heroku 容器化应用程序连接到远程 SQL Server 数据库
- php - Dropzone JS:响应不解析facebook视频iframe
- assembly - 具有大值的 SBYTE 或 SWORD 给出 MASM 错误 A2042
- excel - 自动为每列添加时间戳
- python - 在 Python 中连接字符串和字节
- arrays - 试图通过横向视图在配置单元中使用数组中的值获取多行并分解
- keras - tf.keras.layers.Dense 到底是做什么的?
- configuration - 如何在 Clion 中为现有项目添加配置?
- azure-ad-graph-api - 在 OneNote api 调用中附加 preAuthenticated=true 选项后无法呈现 OneNote 图像资源