Giter Site home page Giter Site logo

Comments (7)

onukselcuk avatar onukselcuk commented on August 17, 2024 12

I found the problem. I'm using the wrong version. Since nuxt.js is still based on vue2 I should be using 4.2.0 version of this package.

from vue-cropperjs.

Agontuk avatar Agontuk commented on August 17, 2024

Provide a sample how you're using it. You can also check the example project.

from vue-cropperjs.

onukselcuk avatar onukselcuk commented on August 17, 2024

I'm using vue typescript in nuxt.js. cropper ref is not recognized. I couldn't find the proper type for it. I'm not sure if it's the only problem. I'm using the same setup in another project and it works fine. But the version is 4.1.0 in that project. I could try downgrading the package but I don't prefer to do it.

    <input
      ref="fileInput"
      accept=".jpg, .jpeg, .png"
      style="display: none"
      type="file"
      @input="onFileSelect"
    />
    <Dialog
      id="upload-profile-photo-dialog"
      :visible.sync="imageCropperPopupActive"
      :style="{ width: '50vw' }"
      :modal="true"
      class="popup-dialog"
    >
      <template #header>
        <div class="header-top-red-line"></div>
        <h2 class="dialog-header">Upload Profile Photo</h2>
      </template>
      <div>
        <div class="w-full h-full">test</div>
        <vue-cropper
          v-show="imageCropperActive"
          ref="cropper"
          :src="selectedFile"
          alt="Source Image"
        ></vue-cropper>
      </div>
    </Dialog>
    ...
    interface $refs {
       cropper: CropperData
       fileInput: HTMLImageElement
	}
    ...
    data(){
      imageCropperPopupActive: false as boolean,
      imageCropperActive: false as boolean,
      selectedFile: '' as string,       
    }
    ...
    methods:{
      onFileSelect(e) {
        const file = e.target.files[0]
        this.mime_type = file.type
        if (typeof FileReader === 'function') {
          this.imageCropperPopupActive = true
          const reader = new FileReader()
          reader.onload = (event) => {
            // @ts-ignore
            this.selectedFile = event.target.result
            this.$refs.cropper.replace(this.selectedFile)
          }
          reader.readAsDataURL(file)
          this.imageCropperActive = true
          e.target.value = ''
        } else {
          alert('Sorry, FileReader API not supported')
        }
      },    
    } 


    

from vue-cropperjs.

CavalcanteLeo avatar CavalcanteLeo commented on August 17, 2024

I'm on version 5, and getting this error

Captura de Tela 2021-06-16 às 03 10 49

from vue-cropperjs.

VladimirMarahovskiy avatar VladimirMarahovskiy commented on August 17, 2024

необходимо понизить версию плагина

from vue-cropperjs.

hassnian avatar hassnian commented on August 17, 2024

I found the problem. I'm using the wrong version. Since nuxt.js is still based on vue2 I should be using 4.2.0 version of this package.

this worked for me!!

from vue-cropperjs.

Edmilson-C avatar Edmilson-C commented on August 17, 2024

I found the problem. I'm using the wrong version. Since nuxt.js is still based on vue2 I should be using 4.2.0 version of this package.

This worked for me. Thanks!

from vue-cropperjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.