Answer the question
In order to leave comments, you need to log in
When exporting/importing an object in Vue(Nuxt), the contents of the object are supplemented with service data - how to do it right?
I decided to put the JSON content in a separate file:
<script>
//data/Content.vue
export default {
1: { id: 1, title: "title-1", short: "short-1", body: "body-1", icon: "", slug: "" },
2: { id: 2, title: "title-2", short: "short-2", body: "body-2", icon: "", slug: "" }
}
</script>
//pages/index.vue
...
import Content from "@/data/Content";
...
data() {
return {
content: Content
};
}
...
<template>
<div>
{{content}}
{ "1": { "id": 1, "title": "title-1", "short": "short-1", "body": "body-1", "icon": "", "slug": "" }, "2": { "id": 2, "title": "title-2", "short": "short-2", "body": "body-2", "icon": "", "slug": "" }, "beforeCreate": [ null ], "beforeDestroy": [ null ], "__file": "data/Content.vue" }
v-for
these things, they are also displayed, but I, of course, do not need this. export default [{ id: 1, title: "title-1", short: "short-1", body: "body-1", icon: "", slug: "" }, { id: 2, title: "title-2", short: "short-2", body: "body-2", icon: "", slug: "" }]
<script>...</script>
in the content file at all? I tried - without it does not work. But is it somehow possible? Answer the question
In order to leave comments, you need to log in
It's funny, but why not just include the .json file?
into a separate vue file?
<script>
//data/Content.vue
export default {
1: { id: 1, title: "title-1", short: "short-1", body: "body-1", icon: "", slug: "" },
2: { id: 2, title: "title-2", short: "short-2", body: "body-2", icon: "", slug: "" }
}
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question