[Vuejs]-Importing Files with nuxt.js (Vue equivalent of getElementById())

1👍

Remove () from the change event:

<input type="file" accept=".obj" id="file" ref="OBJImport" name="objFile" @change="loadFileAsText" single />

Use the default event parameter

methods: {  
  loadFileAsText: function(e) {
    if(process.client) {
      //this.files = this.$refs.OBJImport.files[0];
      //console.log(files); // Here is this.files, not files, this is your initial error.
      this.files = e.target.files[0];
      console.log(this.files);
  }
}

The files you log does not exist, this is your only error.
In addition, I have provided another way to get files.

👤sugars

Leave a comment