往期鸿蒙全套实战文章必看:(附带鸿蒙全栈学习资料)
如何获取router.back传递的参数
在onPageShow回调方法里通过router.getParams方法获取返回值。
参考代码如下:
import { router } from '@kit.ArkUI';
class InfoTmp {
age: number = 0
}
class RouTmp {
id: object = () => {
}
info: InfoTmp = new InfoTmp()
}
const params: RouTmp = router.getParams() as RouTmp; // 获取传递过来的参数对象
const id: object = params.id // 获取id属性的值
const age: number = params.info.age // 获取age属性的值