开发框架:vue
场景:
两个路由:路由1:weixin/h5Form/form.vue;路由1:weixin/h5Form/formNew.vue
进入路由1,根据type==1判断直接跳转到路由1,用的是vue-router
this.$router.replace({ path: "/weixin/h5Form/formNew", query: this.$route.query });
查阅解决方法之一是将vue-router的history模式改为hash模式,但是本项目mode必须是'history',此方法不通;
所有的代码只是在添加了跳转之后二维码识别不出,所以将挑转改为原生跳转,问题完美解决。
const { id,type } = this.$route.query;
if(type == 1){
let location_url = window.location.origin+"/wexin/h5Form/lianmeng" + window.location.search
window.location.replace(location_url);
return
}
<van-overlay :show="showImgModal">
<div class="overlay_wrapper" @click.stop>
<img class="result_img" :src="imgArr[0]" alt="">
</div>
</van-overlay>
此处还需注意点:
- 要识别的二维码必须放到img标签中,而不能采用background-image的形式。
- 二维码必须要显示全,如果有一部分被屏幕或者其他元素遮挡,那是识别不出来的
- 二维码周围不要过于复杂,防止识别算法识别错误
- img不能太小了,不能太模糊,否则都识别不出来
- 网页没有加载完成,微信的识别js没有启动
识别不出二维码:
二维码正常识别出: