組件中未定義的變數
P粉709307865
P粉709307865 2023-09-06 10:48:25
0
1
540

我的伺服器透過 apache2 在 Linux 中運作,但透過 Windows 機器上的 artisan 服務在開發環境中運作得很好。

錯誤是未定義變數$washProgram

  • resources/views/components/expedition-data.blade.php
#
<div>
   Programa {{ $washProgram->name }}
</div>
  • app/View/Components/expeditionData.php
#
<?php

namespace App\View\Components;

use Illuminate\View\Component;

class expeditionData extends Component
{

    public $op;
    public $washProgram;

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($op)
    {
        $this->op = $op;
        $this->washProgram = $op->getSelectedWashProgram();
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        return view('components.expedition-data');
    }
}
  • 呼叫 Blade 中的元件
<x-expedition-data :op="$op" />

我想使用該元件產生一個視圖,但它給了我這個錯誤。

P粉709307865
P粉709307865

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!