简体   繁体   English

我如何在 laravel 刀片中使用 vuejs 组件?

[英]how i can use vuejs component in laravel blade?

the idea is to use vue component inside file blade but i got this error这个想法是在文件刀片中使用 vue 组件,但我收到了这个错误

Failed to mount component: template or render function not defined.

this my importation in app.js这是我在 app.js 中的导入

Vue.component('Notification' ,require('./components/Notification.vue'));

this my component code这是我的组件代码

<template>
     <li class="nav-item dropdown">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="fas fa-bell"></i> <span class="badge badge-light">{{unreads.length}}</span>
          <span class="badge badge-warning navbar-badge"></span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
  <notification-item> </notification-item>


        </div>
      </li>

</template>

<script>
    export default {
      props :['unreads','userid'],
        mounted() {
           Echo.private('App.User.'+ this.userid)
    .notification((notification) => {
        console.log(notification);
    });
        }
    }
</script>

and finally this my code in home.blade.php最后这是我在 home.blade.php 中的代码

<Notification  :userid="{{auth()->id()}}" :unreads="{{auth()->user()->unreadNotifications}}"> </Notification>

someone help me please请有人帮助我

Compile vuejs files via npm run dev and make sure that you use the correct binding for userid and include app.js into scripts.通过npm run dev并确保使用正确的userid绑定并将 app.js 包含到脚本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM