Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mui
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mui
Commits
0d1943cf
Commit
0d1943cf
authored
Sep 24, 2014
by
hbcui1984
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用subpage完善webview模式选项卡
parent
c76be454
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
73 deletions
+30
-73
examples/hello-mui/examples/tab-webview-main.html
examples/hello-mui/examples/tab-webview-main.html
+30
-73
No files found.
examples/hello-mui/examples/tab-webview-main.html
View file @
0d1943cf
...
@@ -53,83 +53,40 @@
...
@@ -53,83 +53,40 @@
</a>
</a>
</nav>
</nav>
<script
type=
"text/javascript"
charset=
"utf-8"
>
<script
type=
"text/javascript"
charset=
"utf-8"
>
//选项卡设计思路:
//1、第一个选项卡对应webview,作为入口页面,主页面加载后需立即展现
var
subpages
=
[
'
tab-webview-subpage-phone.html
'
,
'
tab-webview-subpage-chat.html
'
,
'
tab-webview-subpage-contact.html
'
,
'
tab-webview-subpage-map.html
'
];
//故将其作为子页面append到主窗口,这样主窗口预加载时,会同时预加载子页面;
var
subpage_style
=
{
//2、其它选项卡对应webview,不会立即展现,故可在主页面显示时,再进行预加载;
top
:
'
48px
'
,
mui
.
init
({
bottom
:
'
50px
'
subpages
:[{
};
url
:
'
tab-webview-subpage-phone.html
'
,
//创建子页面,首个选项卡页面显示,其它均隐藏;
id
:
'
tab-webview-subpage-phone.html
'
,
mui
.
plusReady
(
function
(){
styles
:{
var
self
=
plus
.
webview
.
currentWebview
();
top
:
'
48px
'
,
for
(
var
i
=
0
;
i
<
4
;
i
++
){
bottom
:
'
50px
'
var
sub
=
plus
.
webview
.
create
(
subpages
[
i
],
subpages
[
i
],
subpage_style
);
}
if
(
i
>
0
){
}],
sub
.
hide
();
preloadPages
:[{
url
:
'
tab-webview-subpage-chat.html
'
,
id
:
'
tab-webview-subpage-chat.html
'
,
styles
:{
top
:
'
48px
'
,
bottom
:
'
50px
'
}
},{
url
:
'
tab-webview-subpage-contact.html
'
,
id
:
'
tab-webview-subpage-contact.html
'
,
styles
:{
top
:
'
48px
'
,
bottom
:
'
50px
'
}
}
},{
self
.
append
(
sub
);
url
:
'
tab-webview-subpage-map.html
'
,
id
:
'
tab-webview-subpage-map.html
'
,
styles
:{
top
:
'
48px
'
,
bottom
:
'
50px
'
}
}
}]
});
});
//当前激活选项,默认为第一个;
//当前激活选项,默认为第一个;
var
firstTab
=
activeTab
=
'
tab-webview-subpage-phone.html
'
;
var
activeTab
=
subpages
[
0
]
;
//选项卡点击事件
//选项卡点击事件
$
(
'
.mui-bar-tab
'
).
on
(
'
tap
'
,
'
a
'
,
function
(
e
)
{
mui
(
'
.mui-bar-tab
'
).
on
(
'
tap
'
,
'
a
'
,
function
(
e
)
{
var
targetTab
=
this
.
getAttribute
(
'
href
'
);
var
targetTab
=
this
.
getAttribute
(
'
href
'
);
if
(
targetTab
==
activeTab
)
{
if
(
targetTab
==
activeTab
)
{
return
;
return
;
}
}
//当前为第一个选项卡,则仅显示目标选项卡即可;
if
(
activeTab
==
firstTab
){
$
.
openWindow
({
url
:
targetTab
,
id
:
targetTab
,
show
:{
aniShow
:
'
none
'
}});
}
else
{
//如果目标选项卡为第一个选项卡,则直接隐藏当前选项卡即可;
if
(
targetTab
==
firstTab
){
plus
.
webview
.
hide
(
activeTab
);
}
else
{
//先显示目标选项卡,再隐藏当前选项卡
$
.
openWindow
({
url
:
targetTab
,
id
:
targetTab
,
show
:{
aniShow
:
'
none
'
}});
plus
.
webview
.
hide
(
activeTab
);
}
}
activeTab
=
targetTab
;
});
var
defaultBack
=
mui
.
back
;
//先隐藏当前的
mui
.
back
=
function
(){
//先隐藏自己;
defaultBack
();
//再隐藏当前显示的子webview
plus
.
webview
.
hide
(
activeTab
);
plus
.
webview
.
hide
(
activeTab
);
}
//再显示目标
plus
.
webview
.
show
(
targetTab
);
window
.
addEventListener
(
"
pagebeforeshow
"
,
function
(){
//更改当前活跃的选项卡
if
(
activeTab
!==
firstTab
){
activeTab
=
targetTab
;
$
.
openWindow
({
url
:
activeTab
,
id
:
activeTab
,
show
:{
aniShow
:
'
none
'
}});
}
});
});
</script>
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment