2***@qq.com
2***@qq.com
  • 发布:2019-08-09 17:19
  • 更新:2019-08-09 18:43
  • 阅读:957

编译安卓APP后,页面向子组件传值出现异常

分类:uni-app

编译安卓APP后,页面向子组件传值出现异常

该弹出层的组件,传递了一个 :btm 的参数,用来定位当前页面的高度
在H5页面测试下,这个值会被正确的传递过去没有问题。
可是编译到 APP 后这个值没有被正确的传递,也没办法调试。

        <uni-popup :show="openGoods" position="bottom" :msg='this.test' :btm='this.page_scroll' @hidePopup="closeGoods('')">  
            <view class="bottom-title">分享到</view>  
            <view class="bottom-btn" @click="closeGoods('')">取消分享</view>  
        </uni-popup>

页面滚动监听时会更新这个值 。

onPageScroll(e) {  
            this.page_scroll = e.scrollTop * -1;  
            this.$forceUpdate();  
        },

组件内的 style 元素会使用到这个值

<template>  
    <view>  
        <view class="uni-mask" v-show="show" :style="{ top: btm + 'px' }" @click="hide" @touchmove.stop.prevent="moveHandle"></view>  
        <view class="uni-popup" :class="'' + position + ' ' + '' + mode" v-show="show" :style="{ bottom: btm + 'px' }"  >  
            {{ msg }}  
            <slot></slot>  
            <view v-if="position === 'middle' && mode === 'insert'" class=" uni-icon uni-icon-close" :class="{  
                    'uni-close-bottom': buttonMode === 'bottom',  
                    'uni-close-right': buttonMode === 'right'  
                }" @click="closeMask"></view>  
        </view>  
    </view>  
</template>
2019-08-09 17:19 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者)

呃, 自己重新看了一遍文档之后发现问题了

https://uniapp.dcloud.io/use?id=class-%e4%b8%8e-style-%e7%bb%91%e5%ae%9a

非H5端暂不支持在自定义组件上使用 Class 与 Style 绑定

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