0

In my app there's no App.vue component assigned to the #app element. Instead, in my index.html, I have a <router-view> element which displays some Home.vue component by default or whatever other component depending on the route.

However I want to display a certain component (informing about user online status) at all times regardless of the current route. But how can I achieve this if it's not possible to call a component from index.html? Or is it possible?

index.html:

<!DOCTYPE html>
<html lang="en">
  <head><meta charset="utf-8"></head>
  <body>
    <div id="app">
      <!-- Component handling user status (connected / not connected) would go here -->
      <router-view></router-view>
    </div>
    <script src="dist/build.js"></script>
  </body>
</html>
1
  • Can you provide an sample example in JSFiddle? Commented Oct 6, 2018 at 18:45

1 Answer 1

1

Place your component above <router-view> (where the comment indicates <!-- Component handling user status would go here -->):

<div id="app">
  <user-presence-status></user-presence-status>
  <router-view></router-view>
</div>

Be sure to include the component definition when mounting the root component, as shown in the following example:

import UserPresenceStatus from '@/components/UserPresenceStatus';

new Vue({
  el: '#app',
  compnents: {
    UserPresenceStatus
  }
);

demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.