diff --git a/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js b/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js index 32be25762e6ea582640bf1fd5d71972c46ba53fe..41e6248294a121e52cecc91a61979e8efbce4849 100644 --- a/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +++ b/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js @@ -38,6 +38,9 @@ export function parseTitleNView (routeOptions) { ( windowOptions.navigationStyle === 'custom' && !isPlainObject(titleNView) + ) || ( + windowOptions.transparentTitle === 'always' && + !isPlainObject(titleNView) ) ) { return false @@ -56,7 +59,7 @@ export function parseTitleNView (routeOptions) { titleText: titleImage === '' ? windowOptions.navigationBarTitleText || '' : '', titleColor: windowOptions.navigationBarTextStyle === 'black' ? '#000000' : '#ffffff', type: titleNViewTypeList[transparentTitle], - backgroundColor: transparentTitle !== 'always' ? windowOptions.navigationBarBackgroundColor || '#000000' : 'rgba(0,0,0,0)', + backgroundColor: windowOptions.navigationBarBackgroundColor || '#f8f8f8', tags: titleImage === '' ? [] : [{ 'tag': 'img', 'src': titleImage, diff --git a/src/platforms/h5/components/page/index.vue b/src/platforms/h5/components/page/index.vue index 2edb68f0f74917485bfc16b41a8ac14f5770ebd0..666edd7c4ad8651acff28b6384ff7ad42b05f25f 100644 --- a/src/platforms/h5/components/page/index.vue +++ b/src/platforms/h5/components/page/index.vue @@ -39,6 +39,10 @@ import { NAVBAR_HEIGHT } from 'uni-helpers/constants' +import { + isPlainObject +} from 'uni-shared' + import { mergeTitleNView } from 'uni-helpers/patch' @@ -164,13 +168,27 @@ export default { } // 将 navigationStyle 和 transparentTitle 都合并到 titleNView let titleNView = this.titleNView - titleNView = Object.assign({}, { - type: this.navigationStyle === 'custom' ? 'none' : 'default' - }, this.transparentTitle in titleNViewTypeList ? { - type: titleNViewTypeList[this.transparentTitle] - } : null, typeof titleNView === 'object' ? titleNView : (typeof titleNView === 'boolean' ? { - type: titleNView ? 'default' : 'none' - } : null)) + if ( // 无头 + titleNView === false || + titleNView === 'false' || + ( + this.navigationStyle === 'custom' && + !isPlainObject(titleNView) + ) || ( + this.transparentTitle === 'always' && + !isPlainObject(titleNView) + ) + ) { + titleNView = { type: 'none' } + } else { + titleNView = Object.assign({}, { + type: this.navigationStyle === 'custom' ? 'none' : 'default' + }, this.transparentTitle in titleNViewTypeList ? { + type: titleNViewTypeList[this.transparentTitle] + } : null, typeof titleNView === 'object' ? titleNView : (typeof titleNView === 'boolean' ? { + type: titleNView ? 'default' : 'none' + } : null)) + } const yesNoParseList = { 'YES': true,