【发布时间】:2020-06-25 08:25:23
【问题描述】:
所以我有这个view1.php,我想将不同链接中的不同值传递给view2.php。 我设法传递并获取了值,但是我放在 layout.php 中的 css 对 view2.php 不起作用。 我不知道我在哪里做错了。 除了这个,还有其他方法可以传递不同的值吗?
view1.php
@extends('layouts.layout')
@section('content')
<div>
<a href="/pass/6000"> OP 6000 </a>
<a href="/pass/10000"> OP 10000 </a>
<a href="/pass/20000"> OP 20000 </a>
</div>
@endsection
web.php
Route::get('/pass/{id}','User\MyController@postID');
MyController.php
public function postID($id) {
return view('user.view2', [
'id' => $id
]);
}
view2.php
@extends('layouts.layout')
@section('content')
<div>
{{$id}}
</div>
@endsection
layout.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<link rel="stylesheet" type="text/css" href="css/materialize.css" media="screen,projection"/>
<link rel="stylesheet" href="css/bootstrap/bootstrap.css">
<link rel="stylesheet" href="css/user.css">
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<nav> </nav>
<main class="">
@yield('content')
</main>
<footer> </footer>
@yield('alert')
</body>
<script type="text/javascript" src="js/materialize.min.js"></script>
</html>
【问题讨论】:
-
将
href="css更改为href="/css或使用 Laravel 的资产助手。还有src="/js而不是src="js -
“将值传递给视图”和“CSS 不呈现”有什么关系?你的问题是什么?
标签: php laravel laravel-5.8