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

home2 게시판 Vue 게시판 사용자 이미지 올린 것 미리보기

사용자 이미지 올린 것 미리보기

5 글 보임 - 1 에서 5 까지 (총 5 중에서)
  • 글쓴이
  • #45140

    유용환
    참가자
    <div class="img">
            <input type="file" id=file @change="fileUpload">
            <label class="upload" for="file">+</label>
            
        </div>
        <div class="imgs" :style="{backgroundImage : `url(${this.$store.state.file_load.name})`}"></div>
    
    
    file_load : '',
    
    
    fileUpload(e){
          this.$store.state.file_load = e.target.files
          console.log(this.$store.state.file_load)
        }
    
    이렇게 해서 실행하면 콘솔에 file이라는 오브젝트 안에 name이라는 것으로 사용자가 올린 이미지의 경로가 올라와 있는데
    이미지가 안보여집니다. 이거 왜 그런건가요
    사용자가 이미지를 올렸을때 보여줄 css는 다 해놓았습니다.
    get 404 이라는 오류도 나오긴 하는데 이건 별 문제가 아니라고해서 그냥 무시했습니다.
    
    #45160

    codingapple
    키 마스터
    firebase 쓰는거면 firebase에 이미지 먼저 업로드하고 그 url을 가져와서 html에 넣는 식으로 코드짭니다
    #45175

    유용환
    참가자
    <form id="contact">
                <fieldset>
                  <input placeholder="글 제목" type="text" tabindex="1" @change="userTitle"  required autofocus>
                </fieldset>
                <fieldset>
                  <textarea placeholder="글 내용" tabindex="5" @change="userContent" required></textarea>
                </fieldset>
                <fieldset>
                  <button name="submit" type="submit" id="contact-submit" @click="more">Submit</button>
                </fieldset>
                
              </form>
    
    
    
    
    userTitle(e){
          // db.collection('user_post').add({title: e.target.value})
          this.$store.state.user_title = e.target.value
          console.log(this.$store.state.user_title)
        },
        userContent(e){
          // db.collection('user_post').add({content : e.target.value})
          this.$store.state.user_content = e.target.value
          console.log(this.$store.state.user_content)
        },
        more(){
            
            db.collection('user_post').add({title : this.$store.state.user_title ,
            content : this.$store.state.user_content})
            console.log(this.$store.state.user_title, this.$store.state.user_content)
        },   => click 했을때
    
    이렇게 하면 콘솔창에는 나타나는데 파이어베이스 데이터베이스에는 안올라오는데 확인 해주실수있나요
    (코드 복붙해서요)
    #45179

    유용환
    참가자
    위의 질문은 제가 잘못올려서 답변 안해도 됩니다.
    <input   type="file" id=file @change="fileUpload">
     <label class="upload" for="file">+</label>
    <img :src="require(`${this.image}`)" width="100px" >
    fileUpload(e){
          var file = e.target.files
          this.url = URL.createObjectURL(file[0])
          this.image = this.url
          console.log(this.image)
        }
    
    <img :src="require(`${this.image}`)" width="100px" > 을 넣으면 이상하게 해당페이지가 모두 사라지게 되는데
    확인해 봤더니 Uncaught (in promise) Error: Cannot find module '' 이런 에러가 나오는데 경로가 없다는 뜻인가요
    왜 이렇게 되는지 잘 모르겠습니다.
    img태그에 사용자가 이미지를 올린것을 넣으려고 합니다.
    #45221

    codingapple
    키 마스터
    require 빼고 this.image만 넣어봅시다
5 글 보임 - 1 에서 5 까지 (총 5 중에서)
  • 답변은 로그인 후 가능합니다.

About

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

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

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