增加router-link组件

master
yutent 2023-08-12 23:11:10 +08:00
parent 248e153995
commit 6e090d0593
1 changed files with 12 additions and 2 deletions

View File

@ -11,7 +11,7 @@ import createWebHistory from './modern-router.js'
export { createWebHashHistory, createWebHistory } export { createWebHashHistory, createWebHistory }
class Router extends Component { class RouterView extends Component {
static props = { static props = {
keepAlive: false, keepAlive: false,
transition: false, transition: false,
@ -78,8 +78,18 @@ class Router extends Component {
} }
} }
class RouterLink extends Component {
render() {
return html`<a class="link"><slot></slot></a>`
}
}
if (!customElements.get('router-view')) { if (!customElements.get('router-view')) {
customElements.define('router-view', Router) customElements.define('router-view', RouterView)
}
if (!customElements.get('router-link')) {
customElements.define('router-link', RouterLink)
} }
export function createRouter( export function createRouter(