Webapp: sample component with an assets fetch
This commit is contained in:
parent
95963f8820
commit
4e8c24b5f3
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"test": "hello"
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
@ -5,10 +5,10 @@ import vue from "@vitejs/plugin-vue";
|
|||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
},
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue