artisticre
1 month ago
178
1
Laravel

Vue script not working

Posted 1 month ago by artisticre

I have this code when on my individual page, does not work. But if I put it in app.js, it works but there is an error because it cant find $user. How do I get it to work on my blade view?

@section('scripts')
  <script>

    var app = new Vue({
      el: '#app',
      data: {
        rolesSelected: {!! $user->roles->pluck('id') !!}
      }
    });

  </script>
@endsection

my layout where I yield scripts

<div class="management-area" id="app">
      
            @yield('content')
                  </div>
                  <script src="{{ asset('js/app.js') }}" defer></script>
    @yield('scripts') 
</body>
</html>

Please sign in or create an account to participate in this conversation.