I'm quite new to symfony and a litte bit experienced in vue.js. After a bit of research I wasn't able to find a solution to my problem.
I have the following problem:
I'm building a multi-page-application with Symfony and vue.js for the frontend. I use a search-form in my template index.html.twig to get information about the given search query from an API.
Therefore I use routing with Symfony. When hitting the search button the URL xxx/search?query=test is called. This URL is handled by my symfony controller which gets data from the API and renders the page search-result.html.twig. I use Vue.js in index.html.twig and I want to use Vue in search-result.html.twig (and other routes and pages) as well, but I'm not quite sure how to use different vue instances on different pages.
I hope I was able to describe the problem properly! Looking forward to your suggestions.
UPDATE:
This is my current infrastructure:
base.html.twig (all other pages inherit from this template):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
</head>
<body>
<div id="app">
{% block body %}{% endblock %}
</div>
</body>
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
</html>
This is how I initialize my vue instance:
import Vue from 'vue';
import App from './App.vue';
new Vue({
render: h => h(App)
}).$mount('#app');
From App.vue I then dispatch my different components.
Problem is: When I now open a different twig-file I cannot use a different page layout.
search-result.html.twig? It might also help to see how vue.js is used in yourindex.html.twig, where it's working, as a reference. Maybe it would also help to compare the content of both template files. The relevant part is whether they extend a template and if it differs and if there are any blocks containing javascript.