How to clear the value in the < input type='file' > tag in vue without directly manipulating the dom

problem description

recently found a problem that neither value="value_1" nor v-modle can clear the value in the < input type="file" > tag. If ref is OK, but in this case, it violates the principle of not directly manipulating the real dom. Is there any solution?

related codes

/ / Please paste the code text below (do not replace the code with pictures)
< template >

<input type="file" :value="vaule_1" ref="inputFile">
<button @click="reset"></button>

< / div >
< / template >

< script >
export default {

data() {
    return {
        value_1: ""
    }
},

methods: {
    reset() {
        this.value_1 = ""
        // this.$refs.inputFile = ""
    },

}

}
< / script >

May.14,2021

Test address , mine is achievable

new Vue({
  el: '-sharpapp',
  data:{
    fileInput: ''
  },
  methods:{
    reset(){
      this.fileInput = ''
    }
  }
})

<div id="app">
  <button @click="reset">reset</button>
  <input type="file" v-model="fileInput"/>
  {{fileInput}}
</div>
The key point of

is that you do not bind : value to v-model


this is different from the controlled form of react. You can use the answer model upstairs. When the page is empty, you can call this.$forceUpdate () to force the view to be refreshed


VMI model = "value_1"

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b378a8-2c0ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b378a8-2c0ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?