增加router-link

master
yutent 2023-08-13 23:20:02 +08:00
parent 6e090d0593
commit b068f90f0e
2 changed files with 36 additions and 1 deletions

View File

@ -19,6 +19,8 @@ const RULE_REGEXP =
/(:id)|(\{id\})|(\{id:([A-z\d\,\[\]\{\}\-\+\*\?\!:\^\$]*)\})/g
class Router {
type = 'hash'
#tables = new Map()
#views = new Set()

View File

@ -79,8 +79,41 @@ class RouterView extends Component {
}
class RouterLink extends Component {
static props = {
to: Object,
disabled: false
}
static styles = css`
:host {
display: inline-flex;
}
a {
color: inherit;
text-decoration: inherit;
cursor: pointer;
}
:host([disabled]) a {
opacity: 0.6;
cursor: not-allowed;
}
`
#navigate() {
let type = this.$router.type
if (this.disabled) {
return
}
if (type === 'hash') {
//
} else {
//
}
}
render() {
return html`<a class="link"><slot></slot></a>`
return html`<a @click=${this.#navigate}> <slot></slot></a>`
}
}