Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Extremely wrong approach to development! Do not mix warm with soft. Vue is purely front-end, it should only communicate with the php back-end through API requests. The fact that you generate the front code on the back is a very outdated approach, you don’t need to write like this now from the word at all. So frontend frameworks do not use!
It's better not to do this, but it's possible
var app = new Vue({
el: '.blog',
data: {
mes : '<?= $var ?>'
}
});
Recently there was the same task, on WordPress I screwed Vue. To pass a variable from php, I used the wp_localize_script function, in short, it will output something similar
<script type='text/javascript'>
/* <![CDATA[ */
var object_name = {"some_string":"Some string to translate","a_value":"10"};
/* ]]> *//code>
В соседней ветке рекомендуют так выводить на странице
<code lang="php">
echo sprintf("<script>var json_data = '%s';</script>", json_encode($arr));
</code>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question