Answer the question
In order to leave comments, you need to log in
How to properly write data to vue.js?
Hello.
The backend is Yii 2, the front is Vue.js
ON yii 2 I pass some data to the render
return $this->controller->render(
'catalog/index',
[
'products' => Json::encode($this->query)
]
)
<div class="hidden" id="products"><?= $products; ?></div>
this.products = JSON.parse($('#products').text());
Answer the question
In order to leave comments, you need to log in
Definitely json. At what I would send ajax and receive it. But you can also generate a variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question