Reputation: 1185
I am trying to show a span whenever v-if is equal to true in my child component. Could anyone advice what I did wrong. Currently, I have no idea what I did incorrectly.
Child Component
const cardsTemplate = {
template:
`
<fieldset v-if="show.seach_checkboxes">
<span>HELLO WORLD</span>
</fieldset>
`,
props: ['js_local'],
data() {
return {
show:{
search_checkboxes : {
type: Boolean,
default: true,
}
}
}
},
methods :{
change_boolean : function(reverse_boolean){
this.show[reverse_boolean] = !this.show[reverse_boolean]
console.log(this.show)
},
show_search_template: function(){
this.change_boolean('search_checkboxes')
},
get_search_template : function(){
$.post(this.js_local.ajaxurl,
{action : 'get_search_templates'}
).done((data)=>{
this.name = JSON.parse(data)
}).fail((error)=>{
console.log(error)
})
},
}
}
Upvotes: 0
Views: 349
Reputation: 6831
It looks like you're trying to use data()
with type checking, the same way props
is used. Try this:
data() {
return {
show: {
search_checkboxes: true
}
}
}
Also, in your template HTML, you've misspelled search_checkboxes
, it's missing an "r".
<fieldset v-if="show.seach_checkboxes">
^^^
Upvotes: 3