Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김원진
/
khusat-front
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이준호
2020-11-14 04:06:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cd175d87c56b86dfa595ef02fdb789698e6c19d6
cd175d87
1 parent
e52f3a5e
feat: 서버 통신 코드 수정
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
18 deletions
src/components/card/Card.js
src/pages/SurveyPage.js
yarn.lock
src/components/card/Card.js
View file @
cd175d8
import
React
from
'react'
;
import
'./Card.scss'
;
function
Card
({
data
,
onClick
}){
function
Card
({
data
,
answer
,
onClick1
,
onClick2
}){
// type: true false
return
(
<>
<
div
className
=
"card"
onClick
=
{
onClick
}
>
<
div
className
=
"card"
>
<
div
className
=
"card__desc"
>
{
data
.
question
}
<
/div
>
<
div
className
=
"card__content"
>
{
data
.
answer1
}
<
/div
>
<
div
className
=
"card__content"
>
{
data
.
answer2
}
<
/div
>
<
div
className
=
"card__content"
onClick
=
{
onClick1
}
>
{
data
.
answer1
}
<
/div
>
<
div
className
=
"card__content"
onClick
=
{
onClick2
}
>
{
data
.
answer2
}
<
/div
>
<
/div
>
<
/>
);
...
...
src/pages/SurveyPage.js
View file @
cd175d8
...
...
@@ -34,20 +34,29 @@ import "./SurveyPage.scss";
function
SurveyPage
()
{
const
[
curIdx
,
setCurIdx
]
=
useState
(
0
);
const
[
question
,
setQuestion
]
=
useState
([]);
const
clickToNext
=
()
=>
{
setCurIdx
(
curIdx
+
1
);
}
const
[
answer
,
serAnswer
]
=
useState
([]);
// const clickAns1 = (e) =>{
// setCurIdx(curIdx+1);
// const temp
// }
// const clickAns2 = (e) =>{
// setCurIdx(curIdx+1);
// }
useEffect
(()
=>
{
(
async
()
=>
{
try
{
const
result
=
await
axios
.
get
(
"192.168.0.16:8000/getquestions"
);
setQuestion
(
result
);
console
.
log
(
result
);
}
catch
(
e
){
console
.
log
(
"서버 통신 실패"
);
}
})();
const
getApi
=
async
()
=>
{
const
apis
=
axios
.
create
({
baseURL
:
""
,
withCredentials
:
true
});
const
result
=
await
apis
.
get
(
"http://192.168.0.16:8000/getquestions"
);
console
.
log
(
result
);
return
result
;
}
const
data
=
getApi
();
// setQuestion(data);
// console.log(data);
},[]);
return
(
...
...
@@ -60,8 +69,10 @@ function SurveyPage() {
<
div
className
=
"slider__wrapper"
>
<
Card
key
=
{
data
.
num
}
data
=
{
data
}
onClick
=
{
clickToNext
}
data
=
{
data
}
// onClick1={clickAns1}
// onClick2={clickAns2}
answer
=
{
answer
}
style
=
{{
transform
:
`translateX(
${(
-
30
)
*
curIdx
}
rem)`
,
transition
:
"0.5s"
,
...
...
yarn.lock
View file @
cd175d8
This diff could not be displayed because it is too large.
Please
register
or
login
to post a comment