风晓得
风晓得
  • 发布:2019-02-20 10:44
  • 更新:2020-06-28 15:06
  • 阅读:1692

【报Bug】ios下plus.barcode.create高度属性设置无效

分类:uni-app

[内容]
plus.barcode.create创建的扫码插入到界面的uniapp界面webview对象后,height高度属性在ios下不生效,android生效

重现步骤

  1. util.js
    const barcodeAction = function(height, width, callback) {
    let barcodeObj = null;
    barcodeObj = plus.barcode.create(
    'barcode',
    [plus.barcode.QR, plus.barcode.EAN8, plus.barcode.EAN13, plus.barcode.CODE128], {
    top: '69px',
    // top:'auto',
    height: height + 'px',
    width: width + 'px',
    left: 'auto',
    position: 'absolute',
    frameColor: '#608CF8',
    scanbarColor: '#608CF8',
    background: '#000000'
    }
    );
    barcodeObj.onmarked = function(type, result) {
    callback(result);
    };
    return barcodeObj;
    }
    export default {
    barcodeAction,
    };

  2. example.vue
    <template>
    <view class="packaging-operations-info">
    <view class="barcode" :style="{ height: barcodeWindowHeight + 'px' }">...载入中...</view>
    <infoPanel></infoPanel>
    <uniPopup :show="ppshow" :type="pptype" @hidePopup="hidePopup">
    <subPopup></subPopup>
    </uniPopup>
    </view>
    </template>

<script>
// import sepGrid from '../../../components/sep-grid/index.vue';
// import uniList from '../../../components/packages/uni-list/uni-list.vue';
import uniPopup from '../../../components/packages/uni-popup/uni-popup.vue';
import subPopup from './components/subPopup.vue';
import infoPanel from './components/infoPanel.vue';
import sepUtil from '../../../common/sep/util.js';

export default {
components: { infoPanel, uniPopup, subPopup },
data() {
return {
barcodeWindowHeight: 0,
barcodeObj: null,
aa: 0,
ppshow: false,
pptype: 'bottom'
};
},
mounted: function() {
this.$nextTick(function() {});
},
onLoad() {
this.initBarcodeObj();
},
onShow() {},
onReady() {},
onHide() {},
onUnload() {},
methods: {
/**

  • 初始化原生扫码控件并且获取扫码对象赋值
    */
    initBarcodeObj() {
    const systemInfo = uni.getSystemInfoSync();
    let _windowHeight = systemInfo.windowHeight / 2 - 50;
    let _windowWidth = systemInfo.windowWidth;
    this.barcodeWindowHeight = _windowHeight >= 250 ? _windowHeight : 250;

        let pages = getCurrentPages();  
        let page = pages[pages.length - 1];  
        let currentWebview = page.$getAppWebview();  
        const that = this;  
    
        this.barcodeObj = sepUtil.barcodeAction(  
            this.barcodeWindowHeight,  
            _windowWidth,  
            function(param) {  
                that.aa = param;  
                setTimeout(function() {  
                    that.barcodeObj.start();  
                }, 500);  
            }  
        );  
    
        currentWebview.append(this.barcodeObj);  
    
        this.barcodeObj.start();  
    },  
    hidePopup() {  
        this.ppshow = false;  
        this.initBarcodeObj();  
    }  

    },
    /**

    • 头部按钮点击监听事件
      */
      onNavigationBarButtonTap(obj) {
      switch (obj.index) {
      case 0:
      this.ppshow = true;
      this.barcodeObj.close();
      break;
      }
      }
      };
      </script>

<style lang="scss">
.packaging-operations-info {
.barcode {
display: flex;
justify-content: center;
align-items: center;
}
}
</style>

IDE运行环境说明
[HBuilderX]
[IDE版本号] 1.5.4.20190127
[windows版本号]
[mac版本号]

App运行环境说明
[iOS版本号] 12.1(16B92)
[手机型号] iphone6

联系方式
[QQ]382221079

2019-02-20 10:44 负责人:无 分享
已邀请:
v***@outlook.com

v***@outlook.com

你好,请问你解决了吗?我是Android的设置top:'auto' 无效,没有居中

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