1***@163.com
1***@163.com
  • 发布:2021-01-20 17:48
  • 更新:2021-03-10 20:09
  • 阅读:603

uniapp 页面用barcode扫码控件,切换几次之后就会死到当前页面,实际上已经在扫码页面,但是显示的是上一个页面,请问一下他是手机原因还是页面栈原因

分类:uni-app
    <!--    <view class="container">  

    </view> -->  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                barcode:null  
            }  
        },  
        methods: {  
            creatQRBox() {  
                var pages = getCurrentPages()  
                var page = pages[pages.length - 1]  
                // #ifdef APP-PLUS  
                var currentWebview = page.$getAppWebview() //获取当前页面栈  
                console.log(currentWebview)  
                // #endif  
                this.barcode = plus.barcode.create("barcode", [plus.barcode.QR], {  
                    top: '0rpx',  
                    left: '0rpx',  
                    width: '300rpx',  
                    height: '300rpx',  
                    position: 'static'  
                })  
                currentWebview.append(this.barcode);  
                this.barcode.onmarked = this.onmarked  
                // this.startQR()  
                this.barcode.start()  
            },  
            onmarked(type, code, file) {  
                console.log(type, code, file);  
                uni.navigateTo({  
                    url:'../orderList/orderdetails'  
                })  
                this.barcode.cancel()  
                // this.closeQR()  
            },  
        },  
        mounted() {  
            this.creatQRBox()  
            // this.start()  
        },  
        onShow() {  
            // console.log(this.barcode)  
            if(this.barcode==null){  
                return  
            }  
            this.barcode.start()  
        },  
        onHide() {   
            console.log('消失')   
            this.barcode.cancel()  
            console.log(this.barcode)  
            // this.closeQR()  
        }  
    }  
</script>  

<style lang="scss" scoped>  
    // .container {  
    //  width: 750rpx;  
    //  min-height: 100vh;  
    //  background-color: #FFFFFF;  
    // }  
</style>

2021-01-20 17:48 负责人:无 分享
已邀请:
1***@163.com

1***@163.com (作者)

这是源代码

日月和明

日月和明

同问

该问题目前已经被锁定, 无法添加新回复