Vaadin Router encountered an uncaught TypeError while trying to process the error: [Vaadin.Router] The router outlet was expected to be a valid DOM Node, but it was null

I have integrated Vaadin Router into my Vue application. Here is an example of what I am trying to achieve: Below is the content of my App.vue file:

<template>

      <HelloWorld/>

</template>

<script>

import HelloWorld from './components/HelloWorld';


export default {
  name: 'App',

  components: {
     HelloWorld,
  }
};
</script>

And here is the content of my HelloWorld.vue file:

<template>

      <div id = "outlet"></div>

</template>

<script>


import {Router} from '@vaadin/router';

const router = new Router(document.getElementById('outlet'));

router.setRoutes([
  {path: '/', component: 'my-web-component-a'},
  {path: '/other', component: 'my-web-component-other'}
]);
export default {
  name: 'HelloWorld',

};
</script>

I have included the scripts for my web components in this application's index.html like so:

<script src = "../assets/my-web-component-a.js"></script>
<script src = "../assets/my-web-component-other.js"></script>

However, upon starting my Vue application, it runs but does not render the web components and throws the following error:

vaadin-router.js?7629:2007 Uncaught (in promise) TypeError: [Vaadin.Router] Expected router outlet to be a valid DOM Node (but got null)
    at Router.__ensureOutlet (vaadin-router.js?7629:2007)
    at Router.__addAppearingContent (vaadin-router.js?7629:2041)
    at eval (vaadin-router.js?7629:1783)

Am I missing something? I am not very familiar with using Vaadin

Answer №1

There is a chance that the "outlet" element is nested within the shadow DOM, where web components encapsulate their elements. In this case, rather than using

document.getElementById('outlet')
, you can access it by using
this.shadowRoot.getElementById('outlet')
.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JQuery for personalized path animations

After developing an android app that sends onTouchEvents points to a web server, I've been able to retrieve motion points JSON data using Ajax. Here is a snippet of the data: {"data":[ {"x":224.28035,"y":235.4906}, {"x":263.32916,"y":219.45718}, {"x" ...

Build an intricate nested array structure using the properties of an object

My data object is structured like this: "parameters": { "firstName": "Alexa", "lastName": "Simpson", "city": "London" } The task at hand involves implementing the followin ...

Is it recommended to use django's render_to_string response with innerHTML?

This is my first Django project, so please bear with me if I'm making some basic mistakes. I'm currently working on a webpage that will display a report in an HTML table. However, I feel like the process I'm using to gather the data and cons ...

Utilizing jquery to showcase the information in a neat and organized table

Having an input text box and a button, I am looking to display dummy data in a table when any number is entered into the input field and the button is clicked. Here is what I have tried: My Approach $("button#submitid").click(function () { $(&quo ...

Halt the iteration process and confirm a true result upon discovering a match between two arrays

I have two databases, one stored in indexedDB and the other in PouchDB (even though I am aware that PouchDB is built on top of indexedDB). The dataset in indexedDB contains a list of rooms, which was saved through a previous page and is now being displaye ...

The rotation of the camera in three.js around the Y Axis appears to be improper

Our project involves developing a VR/Stereoscopic web application using three.js to showcase the camera's viewing angle. For instance, we have set up a "room" scenario with the camera positioned in the center. The camera's rotation is linked to ...

Difficulty arises in AngularJS Material when attempting to access the same object value using ng-model and ng-change

I'm working with angular-material and facing an issue with an md-switch element. The model of the switch is determined by a value in a JavaScript object. However, I want to avoid directly changing the object value when the user toggles the switch. Ins ...

Issues with NodeJS's "readline" module causing prompts not to be displayed

Recently, I decided to have some fun by creating a 'note' manager using NodeJS. However, I ran into an issue when trying to use readline.question() to prompt the user for their input on managing notes. The prompt was not being displayed as expect ...

Which characters are permissible for the id attribute to prevent the jQuery selector from throwing an exception?

I am facing a situation where the id attribute is inputted by an end user. For instance, if the id for a textbox is "11_=11" as entered by the user, then the HTML code will appear like this: <input type="text" id="11_=11"> The corresponding jQuery ...

Having trouble getting my list items to display on individual lines within the foreach loop. It just doesn't seem to be working as expected

In the event listener, I need to ensure that my list items within the forEach loop are not displaying on separate lines. This issue is causing a problem in a lengthy section of code. The goal is to update questions when an answer is clicked from a list. B ...

Understanding Vue.js: Effectively communicating updates between parent and child components using scoped slots

My goal is to develop a component with two slots, where the second slot repeats based on the number of items in the first slot. I have successfully implemented this using scoped slots. However, I noticed that when the data in the first slot is updated, the ...

Implementing server-side range filter in vue-tables-2: A step-by-step guide

I am currently using a server-side VueTables-2 component to display data from the database. The table includes columns with numeric, textual, and date values. My issue lies with filtering the numeric columns. I am trying to incorporate options for range f ...

What is the best way to customize the border color of a disabled Material UI TextField?

I'm struggling to override the default style for disabled Mui TextField components, particularly in changing the border color. Although I successfully altered the label color for disabled fields, I can't seem to get the border color to change. T ...

The JOI validation process is failing to return all error messages, even though the "abort early" option

I have been encountering an issue while trying to validate my payload using a joi schema. Instead of returning the errors specified in the schema, only one error is being displayed. Even when I provide a payload with name as "int", it only shows one custom ...

Dealing with POST redirection and retrieving parameters in Next.js

In a typical scenario, browsers send GET requests and servers return pages. However, in my case, I am making requests to a remote server and need to receive responses. The issue is that the server redirects me back to my page via a POST request with some d ...

Nodejs Websocket integration with the Firefox browser

Currently, I am utilizing Aurora 17 along with Chrome 22 and Firefox 16 in order to develop a basic chat application. My server-side technology is Node 0.8.9. The issue I am experiencing pertains specifically to Firefox, as it fails to establish a connect ...

Retrieve dashboard configurations in AngularJS by making an $http request prior to initiating the dashboard controller

I am currently immersing myself in Angular and tackling a complex dashboard framework all built with Angular. Prior to loading the controllers, I need to fetch various dashboard settings from the server using $HTTP. These settings play a crucial role in de ...

- **Rewrite** this text to be unique:- **Bold

Check out this relevant jsFiddle link Below is a list where I aim to make all occurrences of the word 'Bold' bold: <ul id = "list"> <li>Make this word Bold</li> <li>Bold this as well</li> <ul> ...

Clicking anywhere outside a popup menu in JavaScript will deactivate a toggle and hide it

I have three different menu options: home,Clinic, and About. When I click on the Clinic option, a Megamenu appears, and if I click on it again, the Megamenu is hidden. I want the Megamenu to hide when clicking anywhere on the webpage. The issue is that cu ...

What is the process for making an ajax call in CakePHP?

It may seem obvious, but I've searched the internet and couldn't find any useful or updated information on this topic. I'm attempting to make an ajax request in CakePHP controller to retrieve both view contents and JavaScript code. The aja ...