I'm new to Vue and not used to HTML
I'm trying to import information from a JSON into my interface, to present it to the user.
Here's the JSON style:
[
{
"Title": "SOFT-STARTER",
"Cod": "Produto: 15775931",
"Description": "A soft-starter SSW7000 permite o controle de partida/parada e proteção de motores.",
"Technical_characteristics": ["Corrente nominal", "600 A", "Tensão nominal", "4,16 kV", "Tensão auxiliar", "200-240 V", "Grau de proteção", "IP41", "Certificação", "CE"]
},
{
"Title": "SOFT-STARTER SSW",
"Cod": "Produto: 14223395",
"Description": "A soft-starter SSW7000 permite o controle de partida/parada e proteção de motores de indução trifásicos de média tensão.",
"Technical_characteristics": ["Corrente nominal", "125 A", "Tensão nominal", "6,9 kV", "Tensão auxiliar", "200-240 V", "Grau de proteção", "IP54/NEMA12", "Certificação", "CE"]
}
]
I saw several tutorials, but nothing worked. Here is the status of the current code. This code even runs, but it doesn't bring any data to the 'textarea' of the html. Here's code file EstepeJson.vue:
<template>
<div class="hello">
<textarea v-model="listDataString" rows="20" cols="80"></textarea>
<ul id="items">
<li v-for="(item, index) in listData" :key="index">
{{ `${item.text} [${item.id}]` }}
</li>
</ul>
</div>
</template>
<script>
import axios from "../components/DadosScrapingProdutos.js";
export default {
name: "JsonArq",
props: {
msg: String,
},
data() {
return {
listDataString: '',
listData: [], // placeholder
};
},
mounted() {
axios
.get("=== [API_ENDPOINT] ===")
.then((response) => {
this.listDataString = JSON.stringify(response.data, null, "\t");
this.listData = response.data;
console.log(this.listDataString);
return response; // multiline arrow function must return
});
},
};
</script>
Code from Vue's main file, App.vue, follows:
<template>
<div class="main-container">
<h1 style="color:#0072c6;">Hello</h1>
<p style="text-align:center; color:#0072c6;" >Bem Vindo ao Autocomplete para noticiais <br>
Team, v-1.0<br>
<Autocomplete />
<br>
<JsonArq />
<img src="./components/logo.png" width=250 height=200 alt="Logo WEG" >
</p>
</div>
</template>
<script>
import Autocomplete from './components/Autocomplete.vue'
import JsonArq from './components/EstepeJSON.vue'
export default {
name: 'App',
components: {
Autocomplete,
JsonArq
}
}
</script>
<style>
.main-container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-family: 'Fredoka', sans-serif;
}
h1 {
font-size: 3rem;
}
@import url('https://fonts.googleapis.com/css2?family=Fredoka&display=swap');
</style>