vue electron read file

    <input type="file" @change="handleFileChange" />
    <div v-if="fileContent">{{ fileContent }}</div>

export default {
  data() {
    return {
      fileContent: null,
  methods: {
    handleFileChange(event) {
      const file =[0];
      if (file) {
    readFileContent(file) {
      const reader = new FileReader();
      reader.onload = (event) => {
        this.fileContent =;

This Vue component includes an input element of type "file" and a div to display the content of the read file. The handleFileChange method is triggered when a file is selected, and it calls the readFileContent method passing the selected file. The readFileContent method uses the FileReader API to read the content of the file as text, and the result is stored in the fileContent data property, which is then displayed in the div.