mercredi 26 avril 2017

Is it the optimized way of mixing laravel blade and vuejs

I am currently make the app.blade.php as

<!DOCTYPE html>
<html>

<head>
  <title> abc</title>
  <link rel="stylesheet" href='' />
  <link rel="stylesheet" href='' />

  <script>
    window.Laravel = <?php echo json_encode([
        'csrfToken' => csrf_token(),
    ]); ?>
  </script>
</head>

<body>
  <div class="wrapper" id="app" v-cloak>
    @yield('content')
  </div>
  <script src=""></script>
  <script>
    var vm = new Vue({
      el: '#app',
      @yield('vue')
    });
  </script>
</body>

</html>
And subsequent pages like dashboard.blade.php as
@extends('layouts.app')
@section('title', 'customer :')

@section('content')
<titlebar></titlebar>
<dashboard-page
:data=data
:options=options
@update=updatethedata
><dashboard-page>
@endsection

@section('vue')
data:{
  data:{...},
  options={...},
 },
 methods:{
  updatethdata:function(){
    ...;
  }
 },
 @endsection

It works as intended. but i don't know this is how it should be merged or there as some better ways to do it .

It gives me access to both blade and vue to customize my application . but it makes the code much difficult as the js is in blade file which doesnot get minified. more over none syntax highlighter works , as it is not in a script tag.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire