每日一坑:vue router 使用params方式无法给子组件传参
问题还原
使用params无法在子组件中获取路由参数
<!--示例:发送数据组件-->
...
const type = 'phone';
this.$router.push({ name: 'bind', params: { type: res.type } })
...
<!--接收端-->
...
const type = this.$route.params.type
...
问题解决
将params替换为query实现路由传参
<!--示例:发送数据组件-->
...
const type = 'phone';
this.$router.push({ name: 'bind', query: { type: res.type } })
...
<!--接收端-->
...
const type = this.$route.query.type
...
- 感谢你赐予我前进的力量
                        
                        
                            
赞赏者名单
                            因为你们的支持让我意识到写文章的价值🙏
                        
                    
            本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 木子李
        
     评论
            
                匿名评论
                隐私政策
            
            
                你无需删除空行,直接评论以获取最佳展示效果
            
         
            
        

 
                         
                 
            