L
L
lmentict2019-03-02 01:36:22
Vue.js
lmentict, 2019-03-02 01:36:22

How to use two vue apps on the same page?

Hello, there is such a problem, there is a Yii2 application that uses vue on some pages that use VueRouter. It was decided to add Chat to all pages of this application, that is, to the application template (sliding out on the left). Chat also uses VueRouter, but already mode: "abstact", and on Yii2 pages, vue uses Router with mode: "history". When trying to insert a chat into a chat template, on yii2 views where vuerouter is involved and the chat writes Uncaught TypeError: Cannot redefine property: $router. I read on the Internet that this is due to the fact that it is called both there and there twice vue.use (vueRouter). How can this be cured? Thanks in advance for your replies

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Volintsev, 2019-03-02
@copist

Do not use a router in the chat module. Switch views (components) without changing the URL.
Something like this: in the property, componentsave the code of the current visible part of the application.

<template>
   <app-dialog v-if="component === "dialog"></app-dialog>
   <app-settings v-if="component === "settings"></app-settings>
</template>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question