I am working on a project where i use vue for my frontend, but i am new on vue. And i am trying to add some dynamically class on my table. So for example where i check table-sm table will assing this class. Already i have done this but it work only with one class. I really dont know how to do this to work with an array. Can someone help ?
I want also to add another input for other classes EX: table-bordered and table-striped ...
<div class="form-check form-switch">
<input v-model="smallTable.active" type="checkbox" class="form-check-input" id="smallTable" @change="tableStyles()">
<label class="form-check-label" for="smallTable">
Small Table
</label>
</div>
//Table tag
<table class="table table-hover align-middle mb-0" :class="smallTable.smTable">
...
//vue component
data() {
return {
smallTable: {smTable: "", active: false,},
}
}
tableStyles() {
if (this.smallTable.active) {
this.smallTable.smTable = "table-sm"
}else {
this.smallTable.smTable = ""
}
localStorage.setItem("tableStyle", JSON.stringify(this.smallTable));
},
what i am loking for is something like this:
data() {
return {
smallTable: [
{smTable: "", active: false,},
{bordertable: "", active: false,}
]
}
}
this.smallTable.smTable = "table-sm table-class2 tbl-class3"input type="checkbox"where i can chose different classe i want to add on my table. One checkbox fortable-smone fortable-borderedand some other class maybe