Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
a9b167cb
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a9b167cb
编写于
12月 06, 2018
作者:
郭
郭胜强
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of github.com:dcloudio/uni-app into dev
上级
4b33ffda
4057456c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
25 deletion
+80
-25
src/core/service/bridge/on.js
src/core/service/bridge/on.js
+13
-0
src/platforms/h5/components/app/index.vue
src/platforms/h5/components/app/index.vue
+28
-23
src/platforms/h5/view/components/web-view/README.md
src/platforms/h5/view/components/web-view/README.md
+15
-0
src/platforms/h5/view/components/web-view/index.vue
src/platforms/h5/view/components/web-view/index.vue
+24
-2
未找到文件。
src/core/service/bridge/on.js
浏览文件 @
a9b167cb
...
...
@@ -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
)
}
src/platforms/h5/components/app/index.vue
浏览文件 @
a9b167cb
...
...
@@ -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
>
src/platforms/h5/view/components/web-view/README.md
0 → 100644
浏览文件 @
a9b167cb
# web-view
|属性|完成度|
|:-|:-|
|src|√|
|@message|-|
|方法|完成度|
|:-|:-|
|navigateTo|√|
|redirectTo|√|
|reLaunch|√|
|switchTab|√|
|navigateBack|√|
|getEnv|√|
|postMessage|-|
src/platforms/h5/view/components/web-view/index.vue
浏览文件 @
a9b167cb
<
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录