Yii is not auto including jquery(Yii 不是自动包括 jquery)
问题描述
我对 Yii & 有一个奇怪的问题查询:
I have a strange problem with Yii & Jquery:
当我打开一个在本地主机上使用 ajax/jquery 的页面时,Yii 会自动添加资产包含对页面的调用:
When I open a page which uses ajax/jquery on localhost Yii does automatically add asset include calls to the of the page:
<link rel="stylesheet" type="text/css" href="/PATH/assets/f72b359d/style.css" />
<script type="text/javascript" src="L1BBVEgvYXNzZXRzLzJlNDQyZTFhL2pxdWVyeS5qcw=="></script>
<script type="text/javascript" src="L1BBVEgvYXNzZXRzLzJlNDQyZTFhL2pxdWVyeS5jb29raWUuanM="></script>
然而,当我在服务器上运行相同的代码时,Yii 不会这样做,因为没有可用的 Jquery.
However when I run same code on the server Yii does not do it hense no Jquery available.
如果有人可以直接找到解决方法,我将不胜感激.
I'd appreciate if someone could direct to a way to solve it.
推荐答案
您似乎没有以正确的方式注册 jQuery.您必须在 /protected/views/layout/main.php
中的 </head>
标签之前添加以下行:
It seems like you're not registering jQuery in the correct way. You must add the following line in /protected/views/layout/main.php
before </head>
tag:
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
它会自动加载 jQuery.请记住,如果 YII_DEBUG 标志打开,它将加载非缩小版本,当停用(生产)时,它将加载缩小版本.希望这能解决您的问题.
It will load jQuery automatically. Remember, if the YII_DEBUG flag is on it will load non-minified version, when deactivated (on production) it will load minified version. Hope this will fix your problem.
这篇关于Yii 不是自动包括 jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Yii 不是自动包括 jquery


- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01