提交 3f47718b 编写于 作者: Q qiang

fix: 解决 class 名称中含有 rpx 不生效的问题 question/96981

上级 61d4b4c4
......@@ -221,29 +221,28 @@ function applyToTag (styleElement, obj) {
}
}
//fixed by xxxxxx
var UPX_RE = /([+-]?\d+(\.\d+)?)[r|u]px/g
var VAR_STATUS_BAR_HEIGHT = /var\(--status-bar-height\)/gi
var VAR_WINDOW_TOP = /var\(--window-top\)/gi
var VAR_WINDOW_BOTTOM = /var\(--window-bottom\)/gi
var statusBarHeight = false
function processCss(css) {
//fixed by xxxxxx
var UPX_RE = /([+-]?\d+(\.\d+)?)[r|u]px/g
var VAR_STATUS_BAR_HEIGHT = /var\(--status-bar-height\)/gi
var VAR_WINDOW_TOP = /var\(--window-top\)/gi
var VAR_WINDOW_BOTTOM = /var\(--window-bottom\)/gi
var statusBarHeight = false
function processCss(css) {
if (!uni.canIUse('css.var')) { //不支持 css 变量
if (statusBarHeight === false) {
statusBarHeight = plus.navigator.getStatusbarHeight()
}
}
var offset = {
statusBarHeight: statusBarHeight,
top: window.__WINDOW_TOP || 0,
bottom: window.__WINDOW_BOTTOM || 0
}
css = css.replace(VAR_STATUS_BAR_HEIGHT, offset.statusBarHeight + 'px')
.replace(VAR_WINDOW_TOP, offset.top + 'px')
.replace(VAR_WINDOW_BOTTOM, offset.bottom + 'px')
}
return css
.replace(UPX_RE, function(a, b) {
return uni.upx2px(b) + 'px'
})
}
css = css.replace(VAR_STATUS_BAR_HEIGHT, offset.statusBarHeight + 'px')
.replace(VAR_WINDOW_TOP, offset.top + 'px')
.replace(VAR_WINDOW_BOTTOM, offset.bottom + 'px')
}
return css.replace(/\{.+?\}/gs, css => css.replace(UPX_RE, function (a, b) {
return uni.upx2px(b) + 'px'
}))
}
......@@ -250,9 +250,9 @@ function processCss(css) {
.replace(BODY_SCOPED_RE, page)
.replace(BODY_RE, '')
.replace(PAGE_SCOPED_RE, 'body.' + page + ' uni-page-body')
.replace(UPX_RE, function(a, b) {
.replace(/\{.+?\}/gs, css => css.replace(UPX_RE, function (a, b) {
return uni.upx2px(b) + 'px'
})
}))
}
function getPage() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册