[英]Passing an array to a component in Vue.js 2.0
I am passing an array to a component in Vue.js but it is not passing properly. 我正在将数组传递给Vue.js中的组件,但传递不正确。 Strings pass fine.
字符串可以通过。 My code is below:
我的代码如下:
Vue code Vue代码
<template>
<div class="panel panel-default">
<div class="panel-heading">{{c}}</div>
<div class="panel-body">
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
mounted() {
console.log('Component ready.');
},
props: ['f','c'],
data : function() {
return {
}
},
And the HTML/PHP 还有HTML / PHP
<div class="container">
<div class="row">
<div class="col-md-12">
<?php $a = ['Pasta', 'Chicken', 'Rice']; ?>
<credits f= $a c="One"></credits>
</div>
</div>
</div>
In this case "c" works fine and "f" doesn't. 在这种情况下,“ c”可以正常工作,而“ f”则不能。
How can I do this properly? 如何正确执行此操作?
也许尝试使用json_encode()
对值进行编码,如下所示:
<credits f="<?= json_encode($a)?>" c="One"></credits>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.