diff --git a/packages/uni-template-compiler/lib/app/parser/component-parser.js b/packages/uni-template-compiler/lib/app/parser/component-parser.js index ae2bccfd1f45361da1dd1c024f96d6fde5755412..4df668ac81469f1d78e60d6bc680d1559dfab503 100644 --- a/packages/uni-template-compiler/lib/app/parser/component-parser.js +++ b/packages/uni-template-compiler/lib/app/parser/component-parser.js @@ -10,10 +10,10 @@ const { module.exports = function parseComponent (el) { // 需要把自定义组件的 attrs, props 全干掉 if (el.tag && isComponent(el.tag)) { - // 仅保留 ID + // 仅保留 id、ID、data el.attrs && (el.attrs = el.attrs.filter(attr => { const name = attr.name - return name === ID || name.indexOf('data-') === 0 + return name === 'id' || name === ID || name.indexOf('data-') === 0 })) } -} +} diff --git a/packages/uni-template-compiler/lib/app/parser/tag-parser.js b/packages/uni-template-compiler/lib/app/parser/tag-parser.js index 8579e644b7bffb8a83496e330eea45044eb2db18..0ac94d9801c952ca4f4a67ecfaf2992ed62fd217 100644 --- a/packages/uni-template-compiler/lib/app/parser/tag-parser.js +++ b/packages/uni-template-compiler/lib/app/parser/tag-parser.js @@ -2,16 +2,11 @@ const { hasOwn } = require('../util') -const { - getTagName -} = require('../../h5') - -const tags = require('@dcloudio/uni-cli-shared/lib/tags') +const tags = require('@dcloudio/uni-cli-shared/lib/tags') // 仅限 view 层 module.exports = function parseTag (el) { - el.tag = getTagName(el.tag) if (el.tag.indexOf('v-uni-') !== 0 && hasOwn(tags, el.tag)) { el.tag = 'v-uni-' + el.tag } -} +} diff --git a/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js b/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js index 52e5f4118e90183ebc6624dfcba69832cc19323f..a294c4d1599c06f016916846e3fa38dfdb510d74 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js +++ b/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js @@ -79,7 +79,7 @@ module.exports = function (source) { const isWin = /^win/.test(process.platform) const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) - if(options.compilerOptions){ + if(!options.compilerOptions){ options.compilerOptions = {} } options.compilerOptions.autoComponentResourcePath = normalizePath(resourcePath) diff --git a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js index a01b967d78cdbdf1029e3892d692ca07d256a3f8..23cae5f2873c336a3a0eb76d03a03a9331c3870e 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js @@ -82,13 +82,15 @@ module.exports = function (appJson, manifestJson, { // 删除首页 style 中的 uni-app 配置(不注入 app-view.js) delete manifestJson.plus.launchwebview['uni-app'] - if (appJson.page[appJson.entryPagePath].nvue) { // 首页是 nvue + const entryPagePath = appJson.entryPagePath + if (appJson.page[entryPagePath].nvue) { // 首页是 nvue manifestJson.launch_path = '' // 首页地址为空 manifestJson.plus.launchwebview.uniNView = { - path: appJson.entryPagePath + '.js' + (appJson.entryPageQuery || '') + path: entryPagePath + '.js' + (appJson.entryPageQuery || '') } - if (manifestJson.plus.tabBar) { - manifestJson.plus.tabBar.child = ['lauchwebview'] + const tabBar = manifestJson.plus.tabBar + if (isTabBarPage(entryPagePath, tabBar.list)) { + tabBar.child = ['lauchwebview'] } } else { manifestJson.plus.launch_path = '__uniappview.html' // 首页地址固定 @@ -102,4 +104,4 @@ module.exports = function (appJson, manifestJson, { manifest.content = JSON.stringify(manifest.content) delete appJson.nvue return [manifest, definePages(appJson), appConfigService(appJson)] -} +} diff --git a/src/platforms/app-plus/view/mixins/native.js b/src/platforms/app-plus/view/mixins/native.js index 7f00078436469ab01b5cdacd0ed7a12385741100..b2fe601b262cc6a69fd0af694cf4e03d4c72ef00 100644 --- a/src/platforms/app-plus/view/mixins/native.js +++ b/src/platforms/app-plus/view/mixins/native.js @@ -1,3 +1,32 @@ +const TITLEBAR_HEIGHT = 44 + +function getStatusbarHeight () { + // 横屏时 iOS 获取的状态栏高度错误,进行纠正 + return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0 +} + +function getNavigationBarHeight () { + const webview = plus.webview.currentWebview() + let style = webview.getStyle() + style = style && style.titleNView + if (style && style.type === 'default') { + return TITLEBAR_HEIGHT + getStatusbarHeight() + } + return 0 +} + +function getFixed ($el) { + let fixed + while ($el) { + const style = getComputedStyle($el) + const transform = style.transform || style.webkitTransform + fixed = transform && transform !== 'none' ? false : fixed + fixed = style.position === 'fixed' ? true : fixed + $el = $el.parentElement + } + return fixed +} + export default { name: 'Native', data () { @@ -28,10 +57,13 @@ export default { const rect = (this.$refs.container || this.$el).getBoundingClientRect() this.hidden = rect.width === 0 || rect.height === 0 if (!this.hidden) { - ['top', 'left', 'width', 'height'].forEach(key => { + const position = this.position + position.position = getFixed(this.$el) ? 'absolute' : 'static' + const keys = ['top', 'left', 'width', 'height'] + keys.forEach(key => { let val = rect[key] - val = key === 'top' ? val + (document.documentElement.scrollTop || document.body.scrollTop || 0) : val - this.position[key] = val + 'px' + val = key === 'top' ? val + (position.position === 'static' ? (document.documentElement.scrollTop || document.body.scrollTop || 0) : getNavigationBarHeight()) : val + position[key] = val + 'px' }) } },