1
const EventLevelBoard = {
  name: "EventLevel",
  data: {
    levelStyle: {
      display: "block"
    },
    levelStyleinner: [
      { display: "block" },
      { display: "block" },
      { display: "block" }
    ]
  },
  template: `<ul class="eventlevel" v-bind:style="{data.levelStyle}">
    <li v-for="(item, idx) in eventlist" v-key="idx"  v-bind:style="levelStyleinner[idx]"><strong class="name">{{item.name}}</strong>
    <strong class="size">{{item.size}}</strong></li>
  </ul>`,
  props: {
    eventlist: {
      type: Array
    }
  }
};

Develop Console Error:

data.levelStyle is undefined

data.levelStyleinneris undefined

Why doesn't it find those data properties?

1 Answer 1

1

Because data is not an available property on the component instance, even though it is obviously defined in the options.

You can just access the data directly, like you did here:

v-bind:style="levelStyleinner[idx]"

If you really want to access it through the instance, you could do so through $data:

v-bind:style="$data.levelStyle"

There should be no curly braces { } around the binding.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.