laravel - 如何通过刀片文件中的url传递静态值?
问题描述
我想通过我的刀片文件中的 url 发送静态值。但这不起作用。你能给我解决方案吗
>
> <a href="{{URL::to('/user-login')?rfq=1 }}">This is link</a>
解决方案
你有语法错误,你可以通过
<a href="{{ URL::to('/user-login').'?rfq=1' }}">This is link</a>
这里?rfq=1
这将在''
这个标签下,因为它是字符串
因为您的路由器被定义为这样
Route::get('/user-login/{email}/{password}', 'UserController@user_login')->name('users.user_login');
您应该使用路由名称并像这样传递数据
<a href="{{ route('users.user_login',['email'=>'example@mail.com','password'=> '1234' ]) }}">This is link</a>
那么如果你需要通过,你可以像这样使用
<a href="{{ route('users.user_login',['email'=>'example@mail.com','password'=> '1234','rfq'=>1]) }}">This is link</a>
这将生成像localhost:8000/user-login/example@mail.com/1234?rfq=1"
ref 链接https://laravel.com/docs/8.x/helpers#method-route这样的 url
推荐阅读
- laravel - 在 Laravel 中创建模型会导致数据库错误
- mysql - 如何在mysql中进行查询计算
- c# - 电子邮件发送期间读取值错误之前的 EWS 加载属性
- javascript - 反应日期选择器返回无效日期
- reactjs - 反应:即使没有状态,我可以/应该使用自定义钩子而不是 HOC 吗?
- swift - 如何快速连接蓝牙设备?
- angular - 错误:找不到带有路径的控件:“技能 -> 熟练度”
- apache - 重定向,除非 URL 以特定字符串开头
- datatable - 如何在 Post 返回的数据上呈现 dataTable 上的数据?
- fparsec - 使用 FParsec 中的字符串列表进行解析