H5
https://github.com/weijunfu/app-donation/tree/main/src/pages/publish
浏览器版本: Chrome 84.0.4147.105(正式版本) (64 位)
使用框架: Nerv
在pages/publish/next/index页面中componentWillMount方法中,使用console.log(this.$router.params),直接打印:{id:1, name='wei'}
TypeError: Cannot read property 'params' of undefined
开发工具:vs code 1.50.0
Taro CLI 3.0.11 environment info:
System:
OS: Windows 10
Binaries:
Node: 12.18.4
Yarn: 1.22.4
npm: 6.14.5
我也遇见了,3.0.14版本,用了所有方法都拿不到路由参数,只能自己根据Taro_ENV===h5来自己写js获取路径参数
通过getCurrentInstance获取路由参数
通过getCurrentInstance获取路由参数
Taro.getCurrentInstance() 用这个也不行的啊
我也遇见了,3.0.14版本,用了所有方法都拿不到路由参数,只能自己根据Taro_ENV===h5来自己写js获取路径参数
这岂不是很麻烦
通过getCurrentInstance获取路由参数
Taro.getCurrentInstance()用这个也不行的啊
通过getCurrentInstance获取路由参数
Taro.getCurrentInstance()用这个也不行的啊
你先自己升级到3版本试一下啊,照着文档来没用
通过getCurrentInstance获取路由参数
Taro.getCurrentInstance()用这个也不行的啊你先自己升级到3版本试一下啊,照着文档来没用
我是3.0.9啊,另外个项目是3.1.0-alpha,都是这么取的
通过getCurrentInstance获取路由参数
Taro.getCurrentInstance()用这个也不行的啊你先自己升级到3版本试一下啊,照着文档来没用
我是3.0.9啊
那你升到3.0.14试一下,Currnt,getCurrentInstance,useRouter都获取不到,我们说的是h5环境下
感谢各位,我把Taro降级到v3.0.9 就可以了
注意: 第一点:首先,引入 “getCurrentInstance”,如下:
import Taro, {getCurrentInstance} from '@tarojs/taro'
第二点:使用
let { id } = getCurrentInstance().router.params
这样就可以获取值了
服气。。。竟然还得降级才能拿到参数
服气。。。竟然还得降级才能拿到参数
不一定要降级,_要多看文档_ 。按照下面的,就能获取值
第一点:首先,引入 “getCurrentInstance”,如下:
import Taro, {getCurrentInstance} from '@tarojs/taro'
第二点:使用
let { id } = getCurrentInstance().router.params
这样就可以获取值了
Most helpful comment
注意: 第一点:首先,引入 “getCurrentInstance”,如下:
import Taro, {getCurrentInstance} from '@tarojs/taro'第二点:使用
let { id } = getCurrentInstance().router.params这样就可以获取值了