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
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3