Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
html-project-1
Project
Project
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
gpzhao
html-project-1
Commits
76f03a4a
Commit
76f03a4a
authored
Mar 08, 2019
by
gpzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了第一课练习
parent
da175eaa
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
index.html
单页切换/index.html
+85
-0
jquery.js
单页切换/jquery.js
+0
-0
No files found.
单页切换/index.html
0 → 100644
View file @
76f03a4a
<!DOCTYPE html>
<html>
<head>
<title>
onePage
</title>
<style
type=
"text/css"
>
.page
{
position
:
fixed
;
left
:
0
;
top
:
0
;
width
:
100%
;
height
:
100%
;
}
.hide
{
display
:
none
;}
.bluePage
{
background-color
:
#09c
;}
.orangePage
{
background-color
:
#f60
;}
.grayPage
{
background-color
:
#ccc
;}
</style>
<script
type=
"text/javascript"
src=
"jquery.js"
></script>
<script
type=
"text/javascript"
>
let
router
=
[
{
name
:
'
index
'
,
path
:
'
/index
'
,
title
:
'
首页
'
,
isActive
:
true
},
{
name
:
'
news
'
,
path
:
'
/news
'
,
title
:
'
新闻
'
,
isActive
:
false
},
{
name
:
'
about
'
,
path
:
'
/about
'
,
title
:
'
介绍
'
,
isActive
:
false
}
]
function
refreshHtml
(){
let
htmlContent
=
''
;
let
addClass
=
''
;
for
(
let
i
=
0
;
i
<
router
.
length
;
i
++
){
if
(
router
[
i
].
isActive
){
addClass
=
''
;
}
else
{
addClass
=
'
hide
'
;
}
htmlContent
=
htmlContent
+
"
<div class='page bluePage
"
+
addClass
+
"
' routeName='page-
"
+
router
[
i
].
name
+
"
'>
"
+
router
[
i
].
title
+
"
</div>
"
}
$
(
"
#layout-1
"
).
html
(
htmlContent
);
}
function
changePage
(
pageName
){
let
index
=-
1
;
let
indexActive
=-
1
;
for
(
let
i
=
0
;
i
<
router
.
length
;
i
++
){
if
(
router
[
i
].
name
==
pageName
){
index
=
i
;
}
if
(
router
[
i
].
isActive
){
indexActive
=
i
;
}
}
if
(
index
!=-
1
){
router
[
indexActive
].
isActive
=
false
;
router
[
index
].
isActive
=
true
;
}
else
{
console
.
log
(
"
page not found
"
)
}
refreshHtml
()
}
function
createHtmlPages
(){
changePage
(
"
index
"
)
}
</script>
</head>
<body>
<div
id=
"layout-1"
></div>
</body>
<script
type=
"text/javascript"
>
createHtmlPages
();
changePage
(
"
index
"
)
</script>
</html>
\ No newline at end of file
单页切换/jquery.js
0 → 100644
View file @
76f03a4a
This diff is collapsed.
Click to expand it.
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