Isaac85
Isaac85

Reputation: 53

Vue.js with $this.refs?

<template>
  <div>
    <form>
      <p ref="uploadCvText" @click="openUploadFileDialogueCV(this.$refs.input_file_cv)">+ Upload Your CV (*)</p>
      <input ref="input_file_cv" type="file" value="" name="input_file_cv" @change="handleCvUpload()">
    </form>
  </div>
</template>
<script>
  methods: {
    openUploadFileDialogueCV(e) {
      e.click();
    }
  }
</script>

the problem is that (ref) is not allowed to be used in template ! so how can i refer to html element and let openUploadFileDialogueCV() function works correctly ?

Upvotes: 0

Views: 92

Answers (1)

Igor
Igor

Reputation: 809

Just don't use this in template, use @click="openUploadFileDialogueCV($refs.input_file_cv) instead

Upvotes: 2

Related Questions