<div id="app">
<v-app>
<v-main>
<v-container class="pt-10 pb-5">
<h1 class="text-center py-5">サンプルアプリ(データテーブル/CSV)</h1>
<p class="text-justify px-10 py-5">
使用CSVファイル: <a href="https://www.mhlw.go.jp/content/pcr_case_daily.csv" target="_blank" rel="noreferrer">https://www.mhlw.go.jp/content/pcr_case_daily.csv</a>
</p>
<v-divider></v-divider>
<v-card>
<v-card-title>
<v-text-field v-model="search" append-icon="mdi-magnify" label="Search" single-line hide-details></v-text-field>
</v-card-title>
<v-data-table :headers="headers" :items="items" :search="search"></v-data-table>
</v-card>
</v-container>
</v-main>
</v-app>
<v-overlay :value="isLoading">
<v-progress-circular indeterminate size="64"></v-progress-circular>
</v-overlay>
</div>
new Vue({
el: "#app",
vuetify: new Vuetify(),
data() {
return {
search: "",
headers: [],
items: [],
isLoading: false
};
},
mounted() {
var self = this;
self.isLoading = true;
axios
.get(
//'https://www.mhlw.go.jp/content/pcr_case_daily.csv'
"https://uedayou.github.io/vue-cdn-mashup-sample-apps/vue2/csv/pcr_case_daily.csv"
)
.then(function (response) {
const parsed = Papa.parse(response.data, {
header: true,
skipEmptyLines: true
});
self.setData(parsed.data);
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
self.isLoading = false;
});
},
methods: {
setData: function (data) {
const _headers = [];
for (const d of data) {
const item = {};
for (const key in d) {
item[key] = d[key];
_headers.push(key);
}
this.items.push(item);
}
for (const h of [...new Set(_headers)]) {
this.headers.push({
text: h,
value: h
});
}
}
}
});