I am trying to create some type of tree with vue.js and stuck on a problem with element props. Help me out plz.
I've tried :content="{{tempCont}}"
and I've tried content="{{tempCont}}"
, but none of them worked.
Here's the place where I am using tree
element:
<div id="tree">
<treeItem :title="Parent" :content="{{tempCont}}"></treeItem>
</div>
Here's the entire tree element:
<template>
<div>
<p v-on:click="openTree">{{title}}</p>
<div id="childs" v-if="childVisibility">
<treeItem v-for="item in content" :key="item" title=item>
</div>
</div>
</template>
<script>
export default {
data: {
childVisibility: false
},
methods: {
openTree: function(){
childVisibility = !childVisibility;
}
},
props: {
title: String,
content: Array,
}
}
</script>
<style scoped>
</style>
I am getting this error:
'v-bind' directives require an attribute value. Code Example All Languages >> Javascript >> 'v-bind' directives require an attribute value. “'v-bind' directives require an attribute value.” Code Answer’s
“'v-bind' directives require an attribute value.” Code Answer’s <div v-bind:class=" { active: isActive }"></div> The above syntax means the presence of the active class will be determined by the truthiness of the data property isActive.
When the attribute value within the object changes, it triggers a re-render and the new class is applied. Vue 3 supports a bunch of attribute binding cases using the v-bind directive. It can handle single values, multiple values, boolean attributes as well as CSS style bindings.
Secondly, if you have complex components within your list when you are using v-for and :key is not provided, then whenever the list is changed or re-ordered, it simply changes the DOM but doesn't destroy existing components and that can cause local state mismatch. That is why it is must to have :key attribute.
Use like this: :content="tempCont"
<div id="tree">
<treeItem :title="Parent" :content="tempCont"></treeItem>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With