提交 b87dac4a 编写于 作者: D DCloud_LXH

feat(App-vue): webview support updateTitle

上级 11274522
...@@ -12,7 +12,8 @@ import { NAVBAR_HEIGHT } from 'uni-helpers/constants' ...@@ -12,7 +12,8 @@ import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
let webview = false let webview = false
const insertHTMLWebView = ({ const insertHTMLWebView = ({
htmlId htmlId,
updateTitle
}) => { }) => {
const parentWebview = plus.webview.currentWebview() const parentWebview = plus.webview.currentWebview()
// fixed by hxy web-view 组件所在的 webview 不注入 uni-app 框架 // fixed by hxy web-view 组件所在的 webview 不注入 uni-app 框架
...@@ -32,6 +33,7 @@ const insertHTMLWebView = ({ ...@@ -32,6 +33,7 @@ const insertHTMLWebView = ({
webview = plus.webview.create('', htmlId, styles) webview = plus.webview.create('', htmlId, styles)
if (parentTitleNView) { if (parentTitleNView) {
webview.addEventListener('titleUpdate', function () { webview.addEventListener('titleUpdate', function () {
if (!updateTitle) return
const title = webview.getTitle() const title = webview.getTitle()
parentWebview.setStyle({ parentWebview.setStyle({
titleNView: { titleNView: {
...@@ -45,7 +47,6 @@ const insertHTMLWebView = ({ ...@@ -45,7 +47,6 @@ const insertHTMLWebView = ({
} }
const updateHTMLWebView = ({ const updateHTMLWebView = ({
htmlId,
src, src,
webviewStyles webviewStyles
}) => { }) => {
...@@ -77,6 +78,10 @@ export default { ...@@ -77,6 +78,10 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
updateTitle: {
type: Boolean,
default: true
},
webviewStyles: { webviewStyles: {
type: Object, type: Object,
default () { default () {
...@@ -95,7 +100,8 @@ export default { ...@@ -95,7 +100,8 @@ export default {
mounted () { mounted () {
this.htmlId = WEBVIEW_ID_PREFIX + this.$page.id this.htmlId = WEBVIEW_ID_PREFIX + this.$page.id
insertHTMLWebView({ insertHTMLWebView({
htmlId: this.htmlId htmlId: this.htmlId,
updateTitle: this.updateTitle
}) })
updateHTMLWebView({ updateHTMLWebView({
src: this.$getRealPath(this.src), src: this.$getRealPath(this.src),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册