Using Props to Define the Entry Point of an Application
Since router-view
is a component, it can also receive props. The only prop it receives is name
, which is the same name registered in the corresponding route's record defined in the router
object at the initialization phase.
Any other additional attributes are passed directly to the child component of router-view
during rendering. Here is an example with a class attribute:
<router-view class="main-app-view"/>
If router-view
renders as a child component, we can create an associated template where the layout is defined. A very simple example of a template is as follows:
<template> Â Â <div>Hello World</div> </template>
The child component receives the passed attribute class, and the actual output after rendering becomes the following:
<div class="main-app-view">Hello World</div>
Of course, for our template to be useful, it should...