We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0181b5 commit 032b4abCopy full SHA for 032b4ab
src/v2/guide/migration-vue-router.md
@@ -244,17 +244,17 @@ if (route.meta.requiresAuth) {
244
245
由于 vue-router 将 `?users=Tom` 处理为 `query.users == 'Tom'`,除非你确信数组中的元素将超过一个,你需要检查并在必要时转换该 query 为 数组。
246
247
-一个可行的方案是添加如下类型的 watcher:
+一个可行的方案是添加如下所示的计算属性:
248
249
```javascript
250
-'$route.query.users': {
251
- handler(val) {
252
- this.$route.query.users = Array.isArray(val) ? val : [val]
253
- },
254
- immediate: true
+users () {
+ let val = this.$route.query.users
+ return Array.isArray(val) ? val : [val]
255
}
256
```
257
+然后在用到 `this.$router.query.users` 的地方以计算属性 `users` 代替。
+
258
## Route 匹配
259
260
路由匹配现在使用 [path-to-regexp](https://github.com/pillarjs/path-to-regexp) 这个包,这将会使得工作与之前相比更加灵活。
0 commit comments