fix(nav-bar): prevent getRect (#3822)

fix #3818
This commit is contained in:
rex 2020-12-08 15:25:15 +08:00 committed by GitHub
parent ed834afc44
commit e0335973c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -65,7 +65,9 @@ VantComponent({
wx.nextTick(() => { wx.nextTick(() => {
getRect.call(this, '.van-nav-bar').then((res) => { getRect.call(this, '.van-nav-bar').then((res) => {
if (res && 'height' in res) {
this.setData({ height: res.height }); this.setData({ height: res.height });
}
}); });
}); });
}, },

View File

@ -1,15 +1,11 @@
/* eslint-disable */ /* eslint-disable */
function barStyle(data) { var style = require('../wxs/style.wxs');
var styles = [
['z-index', data.zIndex],
['padding-top', data.safeAreaInsetTop ? data.statusBarHeight + 'px' : 0],
];
return styles function barStyle(data) {
.map(function (item) { return style({
return item.join(':'); 'z-index': data.zIndex,
}) 'padding-top': data.safeAreaInsetTop ? data.statusBarHeight + 'px' : 0,
.join(';'); });
} }
module.exports = { module.exports = {

View File

@ -4,7 +4,7 @@ var object = require('./object.wxs');
function style(styles) { function style(styles) {
return object.keys(styles) return object.keys(styles)
.filter(function (key) { .filter(function (key) {
return styles[key]; return styles[key] != null;
}) })
.map(function (key) { .map(function (key) {
return [key, [styles[key]]].join(':'); return [key, [styles[key]]].join(':');