增加router-link
parent
6e090d0593
commit
b068f90f0e
|
@ -19,6 +19,8 @@ const RULE_REGEXP =
|
|||
/(:id)|(\{id\})|(\{id:([A-z\d\,\[\]\{\}\-\+\*\?\!:\^\$]*)\})/g
|
||||
|
||||
class Router {
|
||||
type = 'hash'
|
||||
|
||||
#tables = new Map()
|
||||
#views = new Set()
|
||||
|
||||
|
|
|
@ -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>`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue