diff --git a/jsr.json b/jsr.json deleted file mode 100644 index 4a326bd..0000000 --- a/jsr.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "@iuroc/vanjs-router", - "version": "2.0.6", - "exports": "./src/router.ts" -} \ No newline at end of file diff --git a/package.json b/package.json index 83ce4f6..7ab529e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "type": "module", "name": "vanjs-router", - "version": "2.0.6", + "version": "2.0.7", "main": "js/router.js", "types": "src/router.ts" } \ No newline at end of file diff --git a/src/router.ts b/src/router.ts index e6e0a7f..0e9135e 100644 --- a/src/router.ts +++ b/src/router.ts @@ -1,9 +1,9 @@ import van, { State } from 'vanjs-core' -/** 返回当前的 Hash 值,自动去除前置 `#`,如果为空则返回 `home` */ -export const nowHash = (): string => location.hash ? location.hash.slice(1) : 'home' +/** 返回当前的 `location.hash` 值的 `#/` 后面的部分,如果为空则返回 `home` */ +export const nowHash = (): string => location.hash ? location.hash.slice(2) : 'home' -/** 当前的 Hash 状态,值通过 `nowHash()` 返回。 */ +/** 当前的 Hash 值,不含开头的 #,值通过 `nowHash()` 返回。 */ export const now: State = van.state(nowHash()) window.addEventListener('hashchange', event => {