php后台
$json = json_encode($data);
return $this->theme->scope($view, ["json"=>$json])->render();
html 页面
<script type="text/javascript">
const $json = JSON.parse('{!! $json !!}');
</script>
js文件可以直接使用$json
alert($json);
php后台
$json = json_encode($data);
return $this->theme->scope($view, ["json"=>$json])->render();
html 页面
<script type="text/javascript">
const $json = JSON.parse('{!! $json !!}');
</script>
js文件可以直接使用$json
alert($json);