FileReader

Forrás:

<template>
  <div id="app">
    <select v-model="enc" @change="f()">
      <option>UTF-8</option>
      <option>ISO-8859-2</option>
    </select>
    <input ref="mf" @change="f()" type="file">
    <pre><code>{{ x }}</code></pre>
  </div>
</template>

<script>
export default {
  data() {
    return {
      x: "", enc: "ISO-8859-2"
    };
  },
  methods: {
    f() {
      var reader = new FileReader();
      reader.onload = e => {
        this.x = e.target.result;
      }
      reader.readAsText(
        this.$refs.mf.files[0], 
        this.enc
      );
    }
  }
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Utoljára frissítve: 2/4/2020, 4:34:44 PM