Pwntastic
Pwntastic

Reputation: 481

Expects an Object or Array value in Vue [ Warn ]

I've been running into a warning that I want to hide/fix. I read you can hide warnings using Vue.config.ignoredElements, and have added the code below in my main.js file:

Vue.config.ignoredElements = [
  'slot v-bind without argument expects an Object',
  'Expected Object, got Array',
  'v-bind without argument expects an Object or Array value'
  ]

Is there a specific option I need to add? or a better way to fix this problem?

This issue might be related: https://github.com/vuejs/vue/issues/6677

Upvotes: 0

Views: 2777

Answers (1)

skirtle
skirtle

Reputation: 29132

I think you've misunderstood. ignoredElements solves a very specific problem.

Typically when Vue is rendering it comes across 3 types of element:

  1. HTML elements, such as <div>.
  2. Special Vue elements, such as <template> or <slot>.
  3. Components, such as <v-select>.

Vue has a list of HTML elements hard-coded so that it can identify the first group. See:

https://github.com/vuejs/vue/blob/399b53661b167e678e1c740ce788ff6699096734/src/platforms/web/util/element.js#L11

If it comes across an element with a name it doesn't recognise it will log an error. Most of the time that's fine but occasionally you might need Vue to treat an unknown element just like a plain HTML element. That can be achieved by adding it to ignoredElements. See https://v2.vuejs.org/v2/api/#ignoredElements for more details.

It is not used to suppress warning messages more generally.

You mentioned three messages:

  1. slot v-bind without argument expects an Object
  2. Expected Object, got Array
  3. v-bind without argument expects an Object or Array value

In all cases these mean that there's a bug in your code. You shouldn't be trying to suppress these warnings, you should be fixing the bugs.

Upvotes: 3

Related Questions