索引控制器如下所示<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;class IndexController extends Controller{ public function index() { return view('welcome'); } public function about() { return view('about'); } public function contact() { return view('contact'); } public function thanks(Request $request) { $request->validate(['firstname' => ['required', 'alpha_num']]); return view('thanks'); }}接觸刀片.php在下面@extends('welcome')@section('content') <div> <h2>Contact Page</h2> <form method="post" action="{{route("thanks")}}"> @csrf<input type="text" name="firstname"/> <input type="submit"/> </form> @if ($errors->any()) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif </div> @endsection謝謝刀片.php@extends('welcome')@section('content')<div> <h2>Thanks</h2>Thank you {{ $firstname }}</div>@endsection歡迎刀片.php <div class="flex-center position-ref full-height"> <div class="content"> <div class="title m-b-md"> app </div> <div class="links"> <a href="{{ route('about') }}">About</a> <a href="{{ route('contact') }}">contact</a> </div> <h1>{{$firstname}}</h1> <div> @yield('content') </div> </div> </div>當我在 welcome.blade 中單擊“聯(lián)系人”時.php它會將我?guī)У健奥?lián)系人”頁面,其中文本框是按壓的 。輸入的值應(yīng)顯示在“謝謝”.php中。我需要在文本框中輸入的值顯示在感謝.blade中.php當我單擊提交時。提前致謝
1 回答

largeQ
TA貢獻2039條經(jīng)驗 獲得超8個贊
數(shù)據(jù)需要顯式傳遞到視圖。出于希望顯而易見的原因,它不能作為變量在全球范圍內(nèi)訪問。
例如
return view('thanks', ['firstname' => 'Your First Name']);
- 1 回答
- 0 關(guān)注
- 132 瀏覽
添加回答
舉報
0/150
提交
取消