我们可以通过在所有跳转的 url 后面添加查询字符串参数进行跳转传参,例如

    1. // 传入参数 id=2&type=test
    2. Taro.navigateTo({
    3. url: '/pages/page/path/name?id=2&type=test'
    4. })

    这样的话,在跳转成功的目标页的生命周期方法里就能通过 this.$router.params 获取到传入的参数,例如上述跳转,在目标页的 componentWillMount 生命周期里获取入参

    1. class C extends Taro.Component {
    2. componentWillMount () {
    3. console.log(this.$router.params) // 输出 { id: 2, type: 'test' }
    4. }
    5. }