我创建了laravel软件包,并显示了基本形式的一个视图test.blade.php,但是当尝试使用route('contact')时,在该形式的内部,它显示了一条错误消息
未定义路线[联系人]。>>
我的路由文件包文件夹中的web.php文件
<?php // matrixhive\testpackage\src\routes\web.php Route::get('contact', function(){ return view('testpackage::test'); }); Route::post('contact', function(){ echo "thanks for submission of form"; }); ?>
我的侧面包装中的查看文件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <title>Contact Us</title> </head> <body> <div style="width: 500px; margin: 0 auto; margin-top: 90px;"> @if(session('status')) <div class="alert alert-success"> {{ session('status') }} </div> @endif <h3>Contact Us</h3> <form action="{{route('contact')}}" method="POST"> @csrf <div class="form-group"> <label for="exampleFormControlInput1">Your name</label> <input type="text" class="form-control" name="name" id="exampleFormControlInput" placeholder="John Doe"> </div> <div class="form-group"> <label for="exampleFormControlInput1">Email address</label> <input type="email" class="form-control" name="email" id="exampleFormControlInput1" placeholder="[email protected]"> </div> <div class="form-group"> <label for="exampleFormControlTextarea1">Enter Your Message</label> <textarea class="form-control"name="message" id="exampleFormControlTextarea1" rows="3"></textarea> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </div> </body> </html>
我正在从here学习laravel软件包开发
我创建了laravel软件包,并有一个视图test.blade.php显示了基本形式,但是当在该形式中尝试使用route('contact')时,它向我显示了一条错误消息Route [contact]未定义。 ...
您需要使用name()
尝试一下