laravel 返回的 json 数据传递给 vuejs

发布时间: 2017-12-29 16:12:21 作者: 大象笔记
var items = {!!  json_encode($items) !!};

注意,外层不要加引号。相当于拼接字符串构成一行代码。

这里用到了 Laravel Blade 模板的取消转义功能

If you don't want the data to be escaped, you may use the following syntax: Hello, {!! $name !!}.

否则,json 中的引号会被转义

[{"appointment_date":"2017-12-28","appointment_price":56465},{"appointment_date":"2018-01-3","appointment_price":654}]
我是一名山东烟台的开发者,联系作者