Answer the question
In order to leave comments, you need to log in
How to connect Vue.js with php?
How to pass data to Vue templates from php? The view component is connected to the page via src in the script. How do you substitute values into a vue component from php for example?
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Feed</title>
</head>
<body>
<div id="app">
<feed></feed>
</div>
<script src="/bundle.js"></script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
> Or is it better to connect front to backend via ajax requests to api?
This.
Use this option:
from php
sometimes you can put some base64 in the form of a tag in html, so that later you can recognize it from javascript. Well, there are different ways.
In php, a page template is generated along with a script block, where json is assigned to a variable, for example, windows.init_data. In a js application, data from window.init_data is passed to the store or to the state of the main component.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question