Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'v-bind' directives require an attribute value

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:Error Image

like image 723
MrLalatg Avatar asked Jan 17 '19 13:01

MrLalatg


People also ask

What is 'V-bind' directive in JavaScript?

'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

What does V-bind require an attribute value for?

“'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.

What is V-bind in VUE 3?

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.

Why we need to have a key attribute in V-for?

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.


1 Answers

Use like this: :content="tempCont"

<div id="tree">
  <treeItem :title="Parent" :content="tempCont"></treeItem>
</div>
like image 184
Sajib Khan Avatar answered Sep 19 '22 17:09

Sajib Khan