const API = "./proverbes.json"
const app = Vue.createApp({
data() {
return {
tabObjets : [],
proverbe : '',
id : 1
}
},
methods : {
async fetchAPI() {
await axios.get(API)
.then((response)=>{
this.tabObjets = response.data
})
.catch((error)=>{
console.log(error)
})
}
}
});
const vm = app.mount('#app'); // mount
spécifie que l'application Vue s'affichera dans la div avec
id="app"
|
const API = "./proverbes.xml"
const app = Vue.createApp({
data() {
return {
id: 0,
monProverbe: '',
}
},
methods : {
async fetchAPI() {
await axios.get(API)
.then((response)=>{
parser = new DOMParser();
xmlDoc = parser.parseFromString(response.data, "text/xml");
mesProverbes = xmlDoc.getElementsByTagName("proverbe");
this.monProverbe = mesProverbes.item((this.id -
1)).firstChild.nodeValue;
})
.catch((error)=>{
console.log(error)
})
}
}
});
const vm = app.mount('#app'); // mount
spécifie que l'application Vue s'affichera dans la div avec
id="app"
|