head 태그 내부에 다음과 같은 링크 추가<script src="https://code.jquery.com/jquery-latest.min.js"></script>
// CSS
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.7/jquery.fullpage.min.css"/>
// JS
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.7/jquery.fullpage.extensions.min.js"></script>
| 속성 | 설명 |
|---|---|
| navigation | false: 기본값 true: 원으로 이루어진 이동 막대기 생성 |
| navigationPosition | none: 기본값 left: 왼쪽 right: 오른쪽 |
이동을 원하는 각 영역에 ‘data-menuanchor’ 클래스 추가
a 태그의 링크와 연결
<li data-menuanchor="menu1">
<a href="#menu1">Slide1</a>
</li>
<footer class="section fp-auto-height"><h1>footer</h1></footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"> </script>
{
"name" : "Soo",
"age" : 20,
"alive" : true,
"hobby" : ["traveling", "piano"]
}
const obj = { name: "Soo",
age: 20,
alive: true,
hobby: ["traveling", "piano"]
};
const json = JSON.stringify(obj);
console.log(json);
// 실행 결과
{"name":"Soo","age":20,"alive":true,"hobby":["traveling","piano"]}
const person = [
{ id: 1, name: "Soo", age: 20 },
{ id: 2, name: "Kim", age: 30 },
{ id: 3, name: "Lee", age: 40 }
];
const json = JSON.stringify(person);
console.log(json);
// 실행 결과
[{"id":1,"name":"Soo","age":20},{"id":2,"name":"Kim","age":30},
{"id":3,"name":"Lee","age":40}]
const obj = { name: "Soo",
age: 20,
alive: true,
hobby: ["traveling", "piano"]
};
// 직렬화
const json = JSON.stringify(obj);
// 역직렬화
const parsed = JSON.parse(json);
console.log(parsed);
// 실행 결과
{ name: 'Soo', age: 20, alive: true, hobby: ['traveling', 'piano'] }
const person = [
{ id: 1, name: "Soo", age: 20 },
{ id: 2, name: "Kim", age: 30 },
{ id: 3, name: "Lee", age: 40 }
];
// 직렬화
const json = JSON.stringify(person);
// 역직렬화
const parsed = JSON.parse(json);
console.log(parsed);
// 실행 결과
[ { id: 1, name: 'Soo', age: 20 },
{ id: 2, name: 'Kim', age: 30 },
{ id: 3, name: 'Lee', age: 40 } ]
fetch(resource, options)
// option은 선택사항
fetch(url, options)
// response 자리에는 객체가 들어옴
// 응답은 response로 들어옴
.then(response => console.log(response))
.catch(error => console.log(error));
$ npm install -g json-server
$ json-server --watch 파일명 --port 포트번호
{
"books": [
{
"id": 1,
"title": "HTML+CSS+자바스크립트",
"publisher": "이지스퍼블리싱",
"price": "30,000"
},
{
"id": 2,
"title": "리액트 프로그래밍 정석",
"publisher": "이지스퍼블리싱",
"price": "36,000"
},
// 생략
]
}
bookList.json 파일의 모든 데이터 읽기
fetch("http://localhost:4000/books")
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.log(error));
bookList.json 파일의 일부 데이터만 읽기
fetch("http://localhost:4000/books")
.then((response) => response.json())
.then((data) => console.log(data[0]))
.catch((error) => console.log(error));
// 실행 결과
{
id: 1,
title: 'HTML+CSS+자바스크립트',
publisher: '이지스퍼블리싱',
price: '30,000'
}
https://developer.mozilla.org/en-US/docs/Web/API/fetch
| 속성 | 설명 |
|---|---|
| method | 데이터 전송 방식 |
| headers | HTTP 요청 헤더 |
| body | HTTP 요청 전문 |