lblblong / tarojs-router-next

Taro 小程序路由库/自动生成带参数类型提示的路由方法/允许传递任意类型、任意大小的参数数据/同步的路由方法调用/koa体验一致的路由中间件
https://lblblong.github.io/tarojs-router-next/
MIT License
248 stars 23 forks source link

能在taro-vue3中使用吗? #9

Closed YHoney7 closed 3 years ago

YHoney7 commented 3 years ago

我在taro-vue3项目中使用, 提示我了一些关于react的报错 1.You might have mismatching versions of React and the renderer (such as React DOM)

lblblong commented 3 years ago

支持在 vue3 中使用的,我添加了一个 vue3 中使用的示例,你可以参考下 https://github.com/lblblong/tarojs-router-next/tree/master/examples/vue3

YHoney7 commented 3 years ago

我能加您个微信吗, 不知道是不是我的使用方式有问题 依旧还是没有起效果

lblblong commented 3 years ago

你这个报错可能是因为 react 和 React DOM 版本不匹配,你更新 react-dom 的版本到最新的试试

YHoney7 commented 3 years ago

这是父页面, 此时我需要跳转至子页面并传入一个'content'的值 1 此时子页面获取数据

YHoney7 commented 3 years ago

这是父页面 此时跳转至子页面并传入一个'content'的值, 跳转是可以进行跳转的 1 然后再在子页面获取数据 2 最后打印的结果为undefined 3

lblblong commented 3 years ago

这是父页面 此时跳转至子页面并传入一个'content'的值, 跳转是可以进行跳转的 1 然后再在子页面获取数据 2 最后打印的结果为undefined 3

你传过去的是 params,Router.getData 是获取不到的,参考以下获取方法

import { getCurrentInstance } from '@tarojs/taro'

onLoad () {
    const params = getCurrentInstance().router?.params,
}

如果在onLoad生命周期像这样也拿不到参数,可以换到 onShow 生命周期去拿参数试试看

YHoney7 commented 3 years ago

谢啦大兄弟, 通过你这种方式可以获取到, 而且你最新更新的useRouterVue不错

lblblong commented 3 years ago

嗯,通过 useRouterVue 拿参数会更好些