【问题标题】:Loop through database table in Laravel Vue js Component循环遍历 Laravel Vue js 组件中的数据库表
【发布时间】:2020-05-30 04:24:58
【问题描述】:

这是我想在vue组件中实现的一个例子

<div v-for="emotion in emotions" class="cb-row">
    <h2>{{ emotion.em_name }}</h2>
</div>

我在 EmotionsController 中创建了一个函数来返回表中的所有数据

class EmotionsController extends Controller
{
    public function getEmotions() {

        $emotions = Emotions::all()->get();

        return $emotions;

    }
}

然后如何将这些数据输入到我的 vue 组件中?它正在加载到表单中

【问题讨论】:

  • 你缺少输入闭包标签
  • 不幸的是仍然有问题。你知道如何将数据库表中的数据导入vue组件吗?
  • 在你的 Laravel 控制器中返回数据,在 Vue 中你可以通过 http get 接收它。看这里:stackoverflow.com/questions/36303720/…
  • 我对 laravel 和 vue 还很陌生。我不太明白如何将数据放入组件中。我可以使用简单的路线吗?

标签: html database laravel vue.js


【解决方案1】:

你必须先参考 laravel 文档。因为它给了你想要的一切。 这是你的问题的链接 https://laravel.com/docs/6.x/frontend#writing-vue-components

【讨论】:

    猜你喜欢
    • 2020-06-08
    • 2019-09-04
    • 2016-10-14
    • 2019-06-18
    • 1970-01-01
    • 2018-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多