• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Vue 게시판 뷰스타그램 강의 중 이미지 관련해서 문의 드립니다.

뷰스타그램 강의 중 이미지 관련해서 문의 드립니다.

  • 이 주제에는 6개 답변, 2명 참여가 있으며 choi2j2 년, 4 월 전에 전에 마지막으로 업데이트했습니다.
7 글 보임 - 1 에서 7 까지 (총 7 중에서)
  • 글쓴이
  • #69658

    choi2j
    참가자
    이미지를 올리고 필터창과 글쓰기 창에는 보이지만 막상 글을 게시하면
    예시 이미지만 나오고 실제 이미지가 적용되지 않습니다.
    
    아래는 코드입니다.
    
    "App.vue"
    <template>
    <div class="header">
    ...
    <Container :post="post" :step="step" :imgd="imgd" @write="written = $event" />
    <div class="footer">
    <ul class="footer-button-plus">
    <input @change="upload" type="file" id="file" class="inputfile" />
    <label for="file" class="input-plus">+</label>
    
    </div>
    </template>
    <script>
    import axios from 'axios';
    import Container from './components/Container.vue';
    import data from './data/data';
    export default {
     name: 'App',
     components: {
     Container,
    },
    data() {
    return {
     post: data,
    ...
     imgd: "",
     written: "",
    }
    },
     methods: {
    ...
    upload(e) {
    let file = e.target.files;
    let url = URL.createObjectURL(file[0]);
     console.log(url);
    this.imgd = url;
    this.step++;
    },
    publish() {
    var myPost = {
     name: "Kim Hyun",
     userImage: "https://placeimg.com/100/100/arch",
     postImage: this.imgd,
     likes: 36,
     date: "May 15",
     liked: false,
     content: this.written,
     filter: "perpetua"
    };
     console.log(myPost);
    this.post.unshift(myPost);
    this.step = 0;
    },
    }
    }
    </script>
    
    위 코드에서 imgd 라는 변수에 이미지 url 데이터를 담았습니다.
    
    #69680

    codingapple
    키 마스터
    이미지 출력하면 잘 나오는지
    이미지를 html에 잘 넣고 있는지 확인해봅시다
    #69687

    choi2j
    참가자
    imgd 를 콘솔로 뽑으면 'blob:http://localhost:8080/세부정보' 이렇게 나오고 이걸 myPost에 넣으면
    postImage: "blob:http://localhost:8080/ef144463-9041-4d7c-8d80-6cf90087b245" 라고 나옵니다.
    뒤에 스타일이 문제인가 싶어서 빼봤지만 제대로 안나와요.
    
    mounted() {
     console.log(this.post.userImage);
    }
    
    한 번 Post 하나씩의 컴포넌트를 출력해봤는데 새로 넣은 사진이 적용이 안되네요
    #69747

    codingapple
    키 마스터
    Post.vue까지 데이터도 잘 전송되고 있나 확인합시다
    #69759

    choi2j
    참가자
    <template>
    <div class="post">
    <div class="post-header">
    <div class="profile" :style="`backgroundImage: url(${post.userImage})`"></div>
    <span class="profile-name">{{ post.name }}</span>
    </div>
    <div class="post-body"></div>
    <div class="post-content">
    <p>{{ post.likes }} Likes</p>
    <p>{{ post.name }} {{ post.content }}</p>
    <p class="date">{{ post.date }}</p>
    </div>
    </div>
    </template>
    <script>
    export default {
     name: "Post",
     props: {
     post: Object,
    },
    mounted() {
     console.log(this.post);
    }
    }
    </script>
    
    Post.vue 이후에도 잘 데이터가 가는 것 같긴 합니다.
    아래의 첫번째는 새로 추가한 거고, 두번째는 원래 있던 포스트입니다.
    
    
    #69797

    codingapple
    키 마스터
    post.postImage 쓰는 부분이 없는듯요 넣어줍시다
    #69822

    choi2j
    참가자
    감사합니다 해결되었습니다
7 글 보임 - 1 에서 7 까지 (총 7 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠