J
J
jazzus2018-12-16 02:21:19
Vue.js
jazzus, 2018-12-16 02:21:19

How to use 2 VUE components on one page?

I am learning Laravel + Vue. You need to place 2 vue components in one Laravel blade template. I know that you can create another id="app2", but somehow it looks ugly :) I need only one component and for this I don't want to make another id in the global app.js. Is there another way to make them work? In theory, no .. But maybe some kind of Laravel trick?
UPDATE
So far, I have found an option - to close access in the template for the second component on conflicting pages.

@if (!(Request::is('signup') || Request::is('login')))
                      <span id="app">
                      <auth></auth>
                      </span>
                  @endif

If anyone has a more interesting solution on how to make parallel components in blade templates (maybe some if condition or something else), I will be grateful for the info

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Shvedov, 2018-12-16
@mmmaaak

And what's the problem? You need two vue instances - call the initialization of the root component twice with the required element id, if you don’t want to render to different elements with different ids, write another level of abstraction so that these two instances are inside the same application and render them in the same application as two neighboring ones component

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question