Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pj-vueTest-project
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
yeahzzzz
pj-vueTest-project
Commits
ecb48ded
Commit
ecb48ded
authored
Mar 08, 2019
by
“yeahzzzz”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vue培训第二课
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
0 deletions
+126
-0
index_pj_2.html
index_pj_2.html
+126
-0
No files found.
index_pj_2.html
0 → 100644
View file @
ecb48ded
<!DOCTYPE html>
<html
lang=
"en"
dir=
"ltr"
>
<head>
<meta
charset=
"utf-8"
>
<title>
demo1
</title>
<script
type=
"text/javascript"
src=
'js/jquery-3.3.1.js'
></script>
<!-- <link rel="stylesheet" href="css/index.css"> -->
</head>
<script
type=
"text/javascript"
>
// function changeState(){
// if ($("#myStatus").html()=='正常') {
// $("#myStatus").html("正在上传")
// } else {
// $("#myStatus").html("正常")
// }
// }
////////////////////////////////////
// let str = 1;
///////////////////////////////////
let
data
=
[
{
key
:
"
str1
"
,
value
:
"
hello
"
},
{
key
:
"
str2
"
,
value
:
"
Welcome to our website
"
},
{
key
:
"
str3
"
,
value
:
"
Pengjisoft
"
},
{
key
:
"
data1
"
,
value
:
"
content2
"
},
{
key
:
'
btData1
'
,
value
:
"
更改我自己的内容
"
},
{
key
:
'
string1
'
,
value
:
'
this is a temp v
'
},
{
key
:
'
string2
'
,
value
:
'
aaa
'
},
]
//更换全都字符串,代码抄的.
String
.
prototype
.
replaceAll
=
function
(
s1
,
s2
){
return
this
.
replace
(
new
RegExp
(
s1
,
"
gm
"
),
s2
);
}
function
setData
(){
let
bodyHtml
=
document
.
body
.
innerHTML
// console.log('bodyHtml'+bodyHtml )
let
bodyHtmlBind
=
bodyHtml
// console.log('bodyHtmlBind:'+bodyHtmlBind )
let
target
,
lable
=
""
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
target
=
"
{{
"
+
data
[
i
].
key
+
"
}}
"
// console.log('target:', target )
lable
=
"
<CON key='
"
+
data
[
i
].
key
+
"
'>
"
+
data
[
i
].
value
+
"
</CON>
"
;
// console.log('lable:', lable )
bodyHtmlBind
=
bodyHtmlBind
.
replaceAll
(
target
,
lable
)
// 主要是这里的次数是data决定的,如何才能是具体内容决定呢?
// $(target).replaceAll(lable);
}
document
.
body
.
innerHTML
=
bodyHtmlBind
;
}
function
setDataItem
(
key
,
value
){
// let btid = btid
console
.
log
(
event
.
target
)
var
target
=
event
.
target
let
index
=
-
1
;
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
data
[
i
].
key
==
key
)
{
data
[
i
].
value
=
value
;
index
=
i
;
break
;
}
}
if
(
index
>=
0
){
// console.log('index:'+ index)
let
bindingDom
=
$
(
target
)
console
.
log
(
'
bindingDom.len:
'
+
bindingDom
.
length
)
// function(event) {
// alert(event.target);
// }
bindingDom
.
html
(
data
[
index
].
value
)
// console.log(data[index].value)
}
}
// function changeMyString(){
// setDataItem('string1',"我...");
// setDataItem('string2',"ni...");
// }
// changeState();
</script>
<body>
<div
class=
"title"
>
状态:
<span
id=
"myStatus"
>
{{str1}}
</span></div>
<button
onclick=
"setData()"
>
上传{{str2}}
</button>
<button
onclick=
"setDataItem('btData1','新的内容')"
id=
"bt2"
>
{{btData1}}
</button>
<button
onclick=
"setDataItem('btData1','新的内容')"
id=
"bt3"
>
{{btData1}}
</button>
<!-- <input type="text" name="" value=""> -->
<!-- <div onclick='changeMyString()'>{{string1}} {{btData1}}</div>
<div class='btData' v-for='item in array1'>{{item.name}}</div> -->
<script
type=
"text/javascript"
>
setData
();
// setDataItem(key,value)
</script>
</body>
</html>
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