A
A
Anton89892018-09-01 19:08:54
Vue.js
Anton8989, 2018-09-01 19:08:54

How to pass data from php to vue.js array?

Good afternoon) There is the following code, how can I pass the values ​​​​100, 200, 300, 400 from php to the vue.js array? thanks in advance)

<div id="app">
  <test></test>
</div>

<script>

Vue.component('test', {
  data() {
    return {
      items:[
       { value: [100, 200] },
        { value: [300, 400] },
      ],
    }
  },
 
  template: '<div> <li v-for="item in items">{{ item.value }}</li></div>'
})

new Vue({
  el: '#app'
});

</script>

Result:
[ 100, 200 ]
[ 300, 400 ]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
serginhold, 2018-09-01
@serginhold

json_encode

B
bini1988, 2018-09-02
@bini1988

Most obvious in php create within tag

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question