【发布时间】:2017-04-17 10:31:40
【问题描述】:
我有一个简单的 Vue 实例,想在没有 HTTP 请求的情况下将 json 从后端传递给 vue,因为它总是一样的。
我试过用道具来做这个,但它不起作用......
在 DOM 中,它看起来像 <div id="my-component" prices="[object Object]">
Vue调试工具将图像显示为空字符串,并在控制台undefined
<div id="my-component" :prices="{{ $prices }}">
</div>
<script>
new Vue({
el: '#my-component',
props: ['prices'],
mounted: function() {
console.log(this.image);
},
});
</script>
其中$prices json 编码数组。
【问题讨论】:
标签: javascript arrays json laravel vue.js