Webapp: sample component with an assets fetch

This commit is contained in:
Francesco 2022-04-22 16:48:46 +02:00
parent 95963f8820
commit 4e8c24b5f3
4 changed files with 47 additions and 9 deletions

View File

@ -1,6 +1,13 @@
<template>
TODO: everything
<main-component></main-component>
</template>
<style>
</style>
<script>
import MainComponent from "./components/MainComponent.vue";
export default {
components: { MainComponent },
};
</script>
<style></style>

View File

@ -0,0 +1,3 @@
{
"test": "hello"
}

View File

@ -0,0 +1,28 @@
<template>
<p>{{ value }}</p>
<a :href="jsonURL">Test</a>
</template>
<script lang="ts">
import jsonURL from "../assets/test.json?url";
export default {
name: "MainComponent",
data() {
return {
value: "Test",
jsonURL: jsonURL,
};
},
mounted() {
fetch(jsonURL)
.then((v) => v.json())
.then((json) => {
console.log(json);
this.value = json;
});
},
};
</script>
<style scoped></style>