You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cef5cfa
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: packages/docs/experimental/param-parsers.md
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,7 +232,29 @@ definePage({
232
232
</script>
233
233
```
234
234
235
-
Hash params are optional. A parser error or a nullish result becomes `null` and does not reject the route. Without a custom getter, an absent hash becomes `null`.
235
+
Hash params are optional by default. A parser error or a nullish result becomes `null`. Set `required: true` to reject the match instead, or provide a default:
-`parser`: parser name. Omit to keep the hash string.
254
+
-`required`: reject the match when parsing fails and no default exists. Defaults to `false`.
255
+
-`default`: a parsed value or factory used when the hash is absent or parsing fails, including for required params. A declared default takes precedence over the getter for an absent hash.
256
+
257
+
Without a custom getter or a default, an absent hash becomes `null`.
236
258
237
259
The parser receives the entire hash string: an empty string when absent, or a string that starts with `#`. To extract several values, return an object from this one parser. Only the deepest matched route's hash parser runs.
238
260
@@ -262,4 +284,4 @@ router.push({
262
284
})
263
285
```
264
286
265
-
You can omit the hash param during navigation or pass `null` to clear it. Nullish values produce an empty hash without calling the setter. The setter returns the entire hash, including `#`, or an empty string. The router then runs the getter to validate and normalize the result.
287
+
You can omit an optional hash param or one with a default during navigation. Pass `null` to clear an optional hash param. Required params without a default must be provided. Nullish values produce an empty hash without calling the setter. The setter returns the entire hash, including `#`, or an empty string. The router then runs the getter to validate and normalize the result.
0 commit comments