Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
online-quiz-react
Commits
46475100
Commit
46475100
authored
Jul 29, 2020
by
baesangjune
Browse files
sessionstorage
parent
5f3cac18
Changes
1
Show whitespace changes
Inline
Side-by-side
src/Home.js
View file @
46475100
...
@@ -8,9 +8,8 @@ function Home() {
...
@@ -8,9 +8,8 @@ function Home() {
<
div
classXName
=
"
Box
"
>
<
div
classXName
=
"
Box
"
>
<
div
className
=
"
Name
"
>
<
div
className
=
"
Name
"
>
이름을
입력하세요
이름을
입력하세요
<
input
onChange
=
{(
event
)
=>
sessionStorage
.
setItem
(
'
name
'
,
event
.
target
.
value
)}
/
>
<
input
onChange
=
{(
event
)
=>
sessionStorage
.
setItem
(
'
name
'
,
event
.
target
.
value
)}
/
>
<
/div
>
<
/div
>
<
button
onClick
=
{(
event
)
=>
checking
(
event
)}
>
이름입력완료
<
/button
>
{
/* sessionStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
{
/* sessionStorage를 사용해야는지 localstorage를 사용해야하는지 */
}
<
/div
>
<
/div
>
...
@@ -26,10 +25,12 @@ function Home() {
...
@@ -26,10 +25,12 @@ function Home() {
}
}
function
checking
(
event
)
{
function
checking
(
event
)
{
if
(
sessionStorage
.
getItem
(
'
name
'
)
===
null
||
sessionStorage
.
getItem
(
'
name
'
).
length
===
0
)
{
if
(
sessionStorage
.
getItem
(
'
name
'
)
===
null
||
sessionStorage
.
getItem
(
'
name
'
).
length
===
0
)
{
alert
(
'
이름을 입력하세요
'
)
alert
(
'
이름을 입력하세요
'
)
// alert('입력하신 이름은'+event.target+'입니다.')
}
else
{
alert
(
'
입력하신 이름은
'
+
sessionStorage
.
getItem
(
'
name
'
)
+
'
입니다.
'
)
}
}
}
}
...
...
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