提交 f1c80512 编写于 作者: L liuxiaohang

fix(app): 修复当页面存在多个weiview,返回时子webview取值有误

上级 7f2e5230
......@@ -19,4 +19,5 @@ export const VD_SYNC_CALLBACK = 'vdSyncCallback'
export const INVOKE_API = 'invokeApi'
export const WEB_INVOKE_APPSERVICE = 'WEB_INVOKE_APPSERVICE'
export const WEBVIEW_INSERTED = 'webviewInserted'
export const WEBVIEW_REMOVED = 'webviewRemoved'
export const WEBVIEW_REMOVED = 'webviewRemoved'
export const WEBVIEW_ID_PREFIX = 'webviewId'
......@@ -3,6 +3,10 @@ import {
ANI_DURATION
} from '../../constants'
import {
WEBVIEW_ID_PREFIX
} from '../../../constants'
import {
setStatusBarStyle
} from '../../bridge'
......@@ -30,7 +34,10 @@ function backWebview (webview, callback) {
if (!children || !children.length) { // 有子 webview
return callback()
}
const childWebview = children[0]
// 如果页面有subNvues,切使用了webview组件,则返回时子webview会取错,因此需要做id匹配
const childWebview = children.find(webview => webview.id.indexOf(WEBVIEW_ID_PREFIX) === 0) || children[0]
console.log('backWebview -> childWebview', childWebview)
childWebview.canBack(({
canBack
}) => {
......
......@@ -4,7 +4,8 @@
<script>
import {
WEBVIEW_INSERTED,
WEBVIEW_REMOVED
WEBVIEW_REMOVED,
WEBVIEW_ID_PREFIX
} from '../../../constants'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
......@@ -92,7 +93,7 @@ export default {
}
},
mounted () {
this.htmlId = 'webviewId' + this.$page.id
this.htmlId = WEBVIEW_ID_PREFIX + this.$page.id
insertHTMLWebView({
htmlId: this.htmlId
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册