簡體   English   中英

"沒有從控制器傳遞到 vue 組件的道具 - vue2 和慣性.js"

[英]Props not passed from controller to vue component - vue2 and inertia.js

我有很多觀點,其中組件是這樣傳遞的

public function Foo(model $model) {
    return Inertia::render('Page/DetailsPage', [
        'prop' => $model,
    ]);
}

建議您不要嘗試從$props $page helper 訪問您的道具,除非您嘗試訪問共享數據

相反,您可以像在任何其他 Vue.js 應用程序中一樣定義您的道具。

<template>
  <div>
    {{ user }}
  </div>
</template>

<script>
  export default {
    props: {
      user: Object,
    }
  }
</script>

有關創建頁面的更多信息

你有沒有深究? 我遇到了我認為類似的問題。 忽略它的邏輯(實驗)​​,我有:

return Inertia::render('Hazards/Create', [
            'entry' => Hazard::first(),
            'projects' => Project::get(['id', 'name']),
            'meta' => [
                'node'                  => Node::get(['id', 'name']),
                'disciplines'           => Discipline::get(['id', 'name']),
            ],
        ]);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM