简体   繁体   中英

Call vue js function with php parameters in blade

I am using vue js cdn in my laravel project. I would like to call a vue js function within blade, but there seems to be an error somewhere (the page loads blank)

<table >
  <head>
   <th>Order ID</th>
   <th>Aging</th>
  </head>
  @foreach($orders as $order) 
   <tr>
     <td>{{ $order->OrderID }}</td>  
     <td>@{{ relativeDate({{ $order }}) }}</td>                                       
    </tr>
  @endforeach    
</table>

However, when I call the function inside a click event, it works

<button @click="relativeDate({{ $order }})">>Button</button> 

mybe you must to show your logic js vue used to handle, i things have error on there.

$order is object and its php, so you have render to js json with relativeDate(<?=json_encode($order)?>)

or render loop via js

insert your $orders be a data on vue component and loop via v-for

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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