php - 如何获取从laravel中的url收集的数据?
问题描述
我试图在刀片模板中使用 if 语句来显示和隐藏基于单击的选项卡的部分。如果我这样做['no' =>'1']
,我会得到$name = 1
。但如果我这样做
['no' =>'{{no}}']
,它什么也不会返回。我应该如何写才能$name = 1
获得['no' =>'{{no}}']
?
网页.php
Route::get('/welcome/{no}', function () {
return view('welcome',['no' =>'{{no}}']);
});
欢迎.blade.php
@if ($no == 1)
@include('post.article')
@else
@include('post.event')
@endif
解决方案
你应该在你的路线中给出这样的:
Route::get('/welcome/{no}', function ($no) {
return view('master/accesslog',['no' =>$no]);
});
这将被视为字符串'{{no}}'
推荐阅读
- c# - 将十进制复制到字节数组中而不进行分配
- python - python中的R等效代码。如何将R代码行转换为python?
- mysql - fetch API 总是返回 {"_U": 0, "_V": 0, "_W": null, "_X": null}
- python - python-constraint的问题设置问题
- python - 如何在我的二进制搜索 Python 代码中修复此错误
- android - 是否可以使用我的 android 设备测试我用颤振制作的应用程序?
- android-studio - 使用 Glide 在空对象引用上出现错误“java.lang.String com.example.bookretrofit.Imagelink.getSmallThumbnail()”
- python-3.x - 多行正则表达式 python,转换为 dict
- node.js - 用户在使用 Sequelize 之前是否喜欢过该帖子
- java - 如果条件为假,则返回 Null