route.params里什么都没有,是空的
时间: 2023-12-13 08:02:37 浏览: 32
如果 `route.params` 是空的,可能有几个原因导致:
1. 在路由定义中,你没有正确地配置动态路由参数。请确保你的路由路径中包含 `:DOCUMENTNAME`,例如 `/documents/:DOCUMENTNAME`,这样才能正确地传递参数。
2. 在使用 `router.push` 进行路由跳转时,你可能没有正确地传递参数。请确保你在 `router.push` 中传递了 `params` 对象。例如:`router.push({ name: 'document', params: { DOCUMENTNAME: 'example' } })`。
3. 如果你正在尝试从嵌套路由中获取参数,可能需要使用 `this.$route.parent.params.DOCUMENTNAME` 来访问父级路由的参数。
请检查以上几点,看看是否有任何问题导致 `route.params` 为空。如果问题仍然存在,请提供更多关于你的路由配置和代码使用的细节,我将尽力帮助你解决问题。
相关问题
routeParams.mViaList.removeIf(avatrViaPoint -> avatrViaPoint.mIsChargePoint);
这是一个Java 8中的Lambda表达式,它的作用是从`routeParams`的`mViaList`列表中移除所有满足`mIsChargePoint`为`true`的元素。Lambda表达式可以看作是一种匿名函数,可以被当作参数传递给某些方法。在这里,`removeIf`方法接受一个`Predicate`对象作为参数,该对象表示一个函数,用于判断某个元素是否需要被移除。Lambda表达式的语法为`(参数列表) -> {函数体}`,其中参数列表可以为空,函数体可以包含多条语句。在这个Lambda表达式中,`(avatrViaPoint -> avatrViaPoint.mIsChargePoint)`是函数体,它表示一个输入参数为`avatrViaPoint`,输出为`avatrViaPoint.mIsChargePoint`的函数。也就是说,该Lambda表达式用于移除所有`mIsChargePoint`为`true`的元素。
mounted(){ this.goods = JSON.parse(localStorage.getItem("goods")) || [] axios({ method:"get", url:"/goodlist" }).then((res)=>{ this.goodList = res.data.goodlist; console.log(res) console.log(this.goodList) this.goodList1 = this.goodList.find( (item) => item.id === this.$route.params.id ) }) }
这是一个Vue.js的生命周期钩子函数 `mounted()`,在组件挂载后被调用。代码中通过 `axios` 发送一个 GET 请求,获取 `/goodlist` 路径的数据。当请求成功后,将返回的数据赋值给 `this.goodList`,并将 `this.$route.params.id` 参数与 `this.goodList` 中的元素进行匹配,找到对应的商品信息并赋值给 `this.goodList1` 变量。同时,代码中还使用了本地存储 `localStorage` 来保存 `this.goods` 变量。如果本地存储中没有 `goods` 变量,则将其赋值为空数组 `[]`。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)