This is a basic illustration of View Router. You can play with the code and try out more ways to use View Router.
For applications with several views, it is better
to instantiate ViewRouter ()
in a separate
'viewrouter.config.js' file and export.
// viewrouter.config.js
import ViewRouter from "https://cdn.skypack.dev/@bukunmikuti/view-router"
let v = new ViewRouter ({...});
export default v
//index.js
import v from './viewrouter.config.js'
v.routeTo(/*id*/)
The mounted()
and render()
can call other methods for
your application logic.
Manipulate elements in the view with mounted()
and put your view on-screen logic in the render()
method.
You can define custom transitions for your views. Simply use
the usual @keyframes animation in your css and reference in view
<template>
tag.
/* index.css */
.customTransition {
animation: myCustom 0.5s ease-in-out forwards;
}
@keyframes {
from {opacity: 0}
to {opacity: 1}
}
<!-- index.html -->
<template id='about' class='v-router customTransition'>
</template>