i'm learning Vue.JS since some days, i'm just tryna doing an app that add a chip on click on a button. The created chips should get the value on of an input as name. I have created a method that (normally), should create this chip. It's not even calling the method and i don't know why, i've tried to console.log something at the beginning of the methods to check it...
Thanks all !
My App.vue :
<template>
<v-app id="whole_container">
<v-content id="main_container">
<v-row id="main_row">
<v-col class="hellocol" id="chips">
<customChip name="Louis"></customChip>
</v-col>
<v-col class="hellocol" id="chipField">
<addChip></addChip>
</v-col>
</v-row>
</v-content>
</v-app>
</template>
<script>
import customChip from './components/chip.vue';
import addChip from './components/addChip.vue';
export default {
name: 'App',
components: {
customChip,
addChip
},
data: () => ({
//
}),
};
</script>
My AddChip file :
<template>
<div>
<v-text-field id="newChip" :outlined="true" label="Entrez un nom" placeholder="Michel" v-model="currentName"></v-text-field>
<p>Je m'appelle {{ currentName }}</p>
<chipButton @click="addChip( currentName )"></chipButton>
</div>
</template>
<script>
import chipButton from './button.vue';
export default {
data: () => ({
currentName: ""
}),
components: {
chipButton,
},
methods: {
addChip: function(name) {
console.log(name);
let actualChips = document.getElementById('chips');
let newChip = document.createElement('customChip');
newChip.name = name;
actualChips.appendChild('newChip');
}
}
}
</script>