I'm working in VueJs and I've created a few components, called SiteList.vue, Site.vue, and CreateSite.vue. These components make up a bigger component hosted in a file called ListContainer.vue. These components all together are a list of websites that the user can reactively add, change the title, and remove sites, and edit function. ListContainer.vue outputs the whole thing to App.vue. Inside App.vue I've created an html table in the template, and call the listcontainer element inside the table tags. I have a button element that I am trying to use to continue creating the listcontainer element inside the tabletags. So instead of just one listcontainer element, the button will be able to create many.
I attempted to make an array that had all the formatting for a template element inside it, but it did not work and felt hacky.
I read the section on dynamic components and I feel like that is much more close, but I just can't wrap my head around how I should do it. I'm genuinely stuck on something I think might be extremely easy...
App.vue
<template> <div id="app"> <!-- Injection goes here -->
<time-component/>
<table>
<tr>
<td><listcontainer/></td>
<td><listcontainer/></td>
<td><div><button @click="listcontainer++">MAKE NEW LIST</button></div></td>
</tr>
</table> </div> </template>
<script>
import TimeComponent from './components/Time.vue'
import listcontainer from "./components/ListContainer.vue"
export default { name: 'App', components: {
TimeComponent,
listcontainer, }, methods:{
addListContainer(){
}
} } </script>
<!-- CSS for global --> <style>
#app { font-family:serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; margin-top: 60px; background-color: #fff; } </style>
ListContainer.vue
<template>
<div class="large-container">
<sitelist @changeLabel="setSiteLabel" :siteListLabel="siteListLabel_d"/>
</div>
</template>
<script>
import sitelist from "./SiteList.vue"
export default {
name: "list-container",
data(){
return {
siteListLabel_d: "",
};
},
methods: {
setSiteLabel(siteListLabel){
this.siteListLabel_d = siteListLabel;
},
},
components: { sitelist }
};
</script>
<style scoped>
.large-container{
padding: 20px;
margin-left: 20px;
margin-top: 200px;
border: 1px solid;
max-width: 400px;
}
</style>