优化router-link组件无初始值的点击事件

master 1.3.4
yutent 2023-12-27 15:50:54 +08:00
parent 137c79fce7
commit fc20ea24d4
2 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "wkitd", "name": "wkitd",
"version": "1.3.3", "version": "1.3.4",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"files": [ "files": [

View File

@ -107,6 +107,7 @@ class RouterLink extends Component {
a { a {
display: flex; display: flex;
align-items: center; align-items: center;
gap: var(--router-link-gap, 0);
width: 100%; width: 100%;
height: 100%; height: 100%;
color: inherit; color: inherit;
@ -119,7 +120,6 @@ class RouterLink extends Component {
cursor: not-allowed; cursor: not-allowed;
} }
` `
#href = '' #href = ''
#navigate() { #navigate() {
@ -144,13 +144,14 @@ class RouterLink extends Component {
? query.replaceAll('?', '') ? query.replaceAll('?', '')
: object2query(query) : object2query(query)
path = path.replace(/^\//, '') path = '/' + path.replace(/^\/+/, '')
this.to = { path, query }
if (params) { if (params) {
path += '?' + params path += '?' + params
} }
return '/' + path return path
} }
activated() { activated() {