提交 a9b167cb 编写于 作者: 郭胜强

Merge branch 'dev' of github.com:dcloudio/uni-app into dev

......@@ -46,6 +46,17 @@ function onAppEnterForeground () {
callCurrentPageHook('onShow')
}
function onWebInvokeAppService ({
name,
arg
}, pageId) {
if (name === 'postMessage') {
// TODO 小程序后退、组件销毁、分享时通知
} else {
uni[name](arg)
}
}
export default function initOn (on) {
on('onError', onError)
on('onPageNotFound', onPageNotFound)
......@@ -57,4 +68,6 @@ export default function initOn (on) {
on('onTabItemTap', createCallCurrentPageHook('onTabItemTap'))
on('onNavigationBarButtonTap', createCallCurrentPageHook('onNavigationBarButtonTap'))
on('onWebInvokeAppService', onWebInvokeAppService)
}
......@@ -6,25 +6,29 @@
<router-view :key="key" />
</keep-alive>
<!-- </transition> -->
<tab-bar
v-if="hasTabBar"
v-show="showTabBar"
<tab-bar
v-if="hasTabBar"
v-show="showTabBar"
v-bind="tabBar" />
<toast
v-bind="showToast"
<toast
v-bind="showToast"
@close="_onModalClose" />
<action-sheet
v-bind="showActionSheet"
<action-sheet
v-bind="showActionSheet"
@close="_onActionSheetClose" />
<modal
v-bind="showModal"
<modal
v-bind="showModal"
@close="_onModalClose" />
<picker
v-bind="showPicker"
<picker
v-bind="showPicker"
@close="_onPickerClose" />
</uni-app>
</template>
<script>
import {
isPlainObject
} from 'uni-shared'
import {
TABBAR_HEIGHT
} from 'uni-helpers/constants'
......@@ -68,24 +72,25 @@ export default {
UniServiceJSBridge.emit('onHidePopup')
},
hideTabBar (newVal, oldVal) {
if (__PLATFORM__ === 'h5') {
// TODO 不支持 css 变量时
if (uni.canIUse('css.var')) {
const windowBottom = !newVal ? (TABBAR_HEIGHT + 'px') : '0px'
document.documentElement.style.setProperty('--window-bottom', windowBottom)
console.debug(`uni.${windowBottom ? 'showTabBar' : 'hideTabBar'}:--window-bottom=${windowBottom}`)
}
// TODO 不支持 css 变量时
if (uni.canIUse('css.var')) {
const windowBottom = !newVal ? (TABBAR_HEIGHT + 'px') : '0px'
document.documentElement.style.setProperty('--window-bottom', windowBottom)
console.debug(`uni.${windowBottom ? 'showTabBar' : 'hideTabBar'}:--window-bottom=${windowBottom}`)
}
}
},
created () {
if (__PLATFORM__ === 'h5') {
if (uni.canIUse('css.var')) {
document.documentElement.style.setProperty('--status-bar-height', '0px')
}
if (uni.canIUse('css.var')) {
document.documentElement.style.setProperty('--status-bar-height', '0px')
}
},
mounted () {
window.addEventListener('message', function (evt) {
if (isPlainObject(evt.data) && evt.data.type === 'WEB_INVOKE_APPSERVICE') {
UniServiceJSBridge.emit('onWebInvokeAppService', evt.data.data, evt.data.pageId)
}
})
document.addEventListener('visibilitychange', function () {
if (document.visibilityState === 'visible') {
UniServiceJSBridge.emit('onAppEnterForeground')
......@@ -106,4 +111,4 @@ export default {
width: 100%;
height: 100%;
}
</style>
</style>
# web-view
|属性|完成度|
|:-|:-|
|src|√|
|@message|-|
|方法|完成度|
|:-|:-|
|navigateTo|√|
|redirectTo|√|
|reLaunch|√|
|switchTab|√|
|navigateBack|√|
|getEnv|√|
|postMessage|-|
<template>
<uni-web-view/>
<uni-web-view>
<iframe
:src="realPath"
frameborder="0"
width="100%"
height="100%" />
</uni-web-view>
</template>
<script>
export default {
name: 'WebView'
name: 'WebView',
props: {
src: {
type: String,
default: ''
}
},
data () {
return {
realPath: this.$getRealPath(this.src)
}
}
}
</script>
<style>
uni-web-view iframe {
position: absolute;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册