1. In the controller
$arr = [
'code' => 1,
'msg' => '测试信息',
'data' => [
'mmcike', 'ncaa'
]
];
$this->assign('arr', $arr);
2. In js
let arr = <?=json_encode($arr)?>;
console.log(arr);
$arr = [
'code' => 1,
'msg' => '测试信息',
'data' => [
'mmcike', 'ncaa'
]
];
$this->assign('arr', $arr);
let arr = <?=json_encode($arr)?>;
console.log(arr);