1.字符串

$this->assign('id',$id);

var health_id = '<?php echo $id;?>';

2-1数组

$this->assign('cycle', ArchivesUtil::CYCLE);
var cycle = eval("(" + '<?php echo json_encode($cycle);?>' + ")");



var mobile = "<?php echo $cycle['mobile']; ?>";

 

2-2

$this->assign('arr', json_encode($arr));
Var arr = {$arr};


例子:json转js数组、遍历key值

 php 后台json 转 js数组

----------------------------------------------------------------------------------------------------------------------

tp5

var info = {$info|raw};

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-01-01
  • 2022-12-23
猜你喜欢
  • 2021-12-09
  • 2021-05-27
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
相关资源
相似解决方案