我必須用一個表格來做這些頁面中的一個,該表格將根據菜肴型別或菜肴型別等搜索一頓飯及其食譜......這是我回傳視圖的功能,但我顯示的行中有一個錯誤下面以粗體顯示:
public static function SearchPage()
{
$DishType = DishType::getAllDishType();
$CuisineType = CuisineType::getAllCuisineType()
return view("vueRecipeSearch", [
'DishType' => DishType::getAllDishType(),
CuisineType::getAllCuisineType()
]);
}
這是我想使用變數的視圖的一部分:
<label for="DishType">Dish type :</label>
<select id="DishType" name ="DishType">
@foreach($DishType as $Dish)
<option value="Dessert">{{$Dish->dish}}</option>
@endforeach
</select>
我想對美食型別做同樣的事情,但不能,因為我不知道如何回傳多個變數..
uj5u.com熱心網友回復:
return view("vueRecipeSearch", [
'DishType' => DishType::getAllDishType(),
'CuisineType' => CuisineType::getAllCuisineType()
]);
然后您可以使用陣列鍵訪問您的刀片檔案:DishType和CuisineType。
uj5u.com熱心網友回復:
顯然可以將兩個變數從控制器發送到刀片。
$dishType' = DishType::getAllDishType();
$cuisineType = CuisineType::getAllCuisineType();
return \view("vueRecipeSearch", compact('dishType', 'cuisineType'));
在刀片檔案上,您必須訪問這兩個變數,例如 by$dishType和$cuisineType。
uj5u.com熱心網友回復:
回傳視圖 ('vueRecipeSearch',compact('dishType', 'cuisineType')); 無需添加正斜杠或反斜杠。簡單的
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/402142.html
標籤:php html 拉拉维尔 laravel-blade
上一篇:Vue鏈接的格式很奇怪
下一篇:我無法從資料庫中的用戶檢索id
