Yii2的View中JS代码添加
直接写
<script>
$(function(){
alert("aaa");
});
<script>
会提示出错,写成
<?php
$js = <<<JS
$(function(){
alert("aaa");
});
JS;
$this->registerJs($js);
?>
可正确执行
文章来自:http://www.cnblogs.com/baby123/p/4762287.html
直接写
<script>
$(function(){
alert("aaa");
});
<script>
会提示出错,写成
<?php
$js = <<<JS
$(function(){
alert("aaa");
});
JS;
$this->registerJs($js);
?>
可正确执行