ItemContent.vue

김형우·2021년 12월 30일
0

node.js

목록 보기
16/26

물품 상세페이지 / 이미지 불러오기 - GET

1. 이미지 불러오기 - 백

async handleData(){
  const url = `/item/selectone?code=${this.code}`; 
  // code인지 no인지 잘 확인할것
  const headers = {"Content-Type":"application/json"};

  const response = await this.axios.get(url, {headers:headers});
  console.log(response.data);
  if(response.data.status === 200){
    this.item = response.data.result; 
    // response.data.result를 this.item에 다 넣음
    console.log(response.data.result); 
  }
}
  • const url = `/item/selectone?code=${this.code}`;
    : 이미지 꺼내올 백엔드 주소
    : code인지 no인지 cno인지 변수확인 잘 할것

  • const headers = {"Content-Type":"application/json"};
    const response = await this.axios.get(url, {headers:headers});
    : headers, response 똑같음
    : GET을 쓴다.

  • this.item = response.data.result;
    : if문 조건을 확인하고,
    : response.data.resultthis.item에 다 넣음


2. 이미지 불러오기 - 프론트

  • <img :src="item.image" style="width:50%;" />
    : item.image에서 불러왔다는 뜻
    : handleData()에서 response.data.resultthis.item에 다 넣음
       
profile
The best

0개의 댓글