I want to pass a php array to a vuejs component.
Here is how I am doing it.
<?php
$number = ['one', 'two', 'three'];
?>
<!-- My vue js component -->
<orderform :orderd="formdata"></orderform>
<script>
const app = new Vue({
el: '#orderform',
data(){
return {
formdata: <?php $number ?>
}
}
});
</script>
Below is the error I am getting in the console
Uncaught SyntaxError: Unexpected token }
When I use it like below. It works fine with no errors.
<?php
$number = ['one', 'two', 'three'];
?>
<!-- My vue js component -->
<orderform :orderd="formdata"></orderform>
<script>
const app = new Vue({
el: '#orderform',
data(){
return {
formdata: ['one', 'two', 'three']
}
}
});
</script>
I will appreciate for any help. Thanks