uni-app 路由参数获取方法 - 使用 this.$route.params
在uni-app中,可以通过this.$route.params来获取路由参数。
示例代码如下:
export default {
mounted() {
const id = this.$route.params.id;
console.log('路由参数:', id);
}
}
在上述代码中,this.$route.params返回一个对象,其中包含了当前路由的参数。我们可以通过.操作符来获取具体的参数,如this.$route.params.id获取id参数。
原文地址: https://www.cveoy.top/t/topic/p7JT 著作权归作者所有。请勿转载和采集!