php 数组 转换 js数组
<?php $unit = \App\Services\ProdService::units(); $unitJson = json_encode($unit); $category = \App\Services\ProdService::Category(); $categoryJson = json_encode($category); ?>
<script language="javascript"> //单位php数组转js数组 var unitJson = '<?php echo $unitJson;?>'; var unit = JSON.parse( unitJson ); //分类php数组转js数组 var categoryJson = '<?php echo $categoryJson;?>'; var category = JSON.parse( categoryJson ); </script>