karol-f / vue-custom-element

Vue Custom Element - Web Components' Custom Elements for Vue.js
https://karol-f.github.io/vue-custom-element/
MIT License
1.97k stars 187 forks source link

v-bind array string prop does not assign to component prop values #209

Closed bgilbert6 closed 4 years ago

bgilbert6 commented 4 years ago

I tried to follow this github issue to set arrays on a prop, but it doesn't seem to work on the custom element:

https://github.com/vuejs/vue/issues/1177

<my-component :my-array="[5, 10]"></my-component>

props: {
    myArray: {
      default: () => [5, 25, 75, 150, 250, -1],
      type: Array
    }
  }

Other props are working no problem.

karol-f commented 4 years ago

Hi, what does it mean "not work". Can You prepare CodeSandbox with example?

Preferably clone https://codesandbox.io/s/vue-template-jk9jv or give GitHub link to repository.

bgilbert6 commented 4 years ago

Thank you for the quick reply. Take a look here: https://codesandbox.io/s/vue-template-ipgie

There is no error but the prop value isn't assigned. Check out the console results:

my-array="works but broken"
["works but broken", __ob__: Observer]

:my-array="['does', 'not', 'work']"
using default values instead of passed :my-array
[5, 25, 75, 150, 250, -1, __ob__: Observer] 
karol-f commented 4 years ago

Hi, here You have 3 examples how to set Array prop - https://codesandbox.io/s/vue-template-rpmi5?file=/src/App.vue

// JS querySelector(".jsProp").myArray = ["JS", "Prop"];



Regards.