How to pass data(json) to vue instance

前端 未结 4 1787
囚心锁ツ
囚心锁ツ 2020-12-31 23:53

I have a simple Vue instance and want to pass json from the backend to vue without HTTP request because it\'s always the same.

I\'ve tried do this with props, but it

4条回答
  •  既然无缘
    2021-01-01 00:33

    While this op is old, here is how I would do it (inspired by how I do it in Symfony 4 + VueJS):

    This is obviously assuming that $prices is a blade variable.

    Note: I used @json() above when $prices is a simple object that can be encoded with json_encode() (underlying function being used when you call blade json function. If however the object is complex, consider using JMS Serializer with @MaxDepth annotations if objects become too complex.

提交回复
热议问题