- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
遇到了一些障碍,我找不到任何支持文档。我的用例相当简单。 Application
模块具有应进入头部的 javascript,而我的其他模块之一 Foo
也具有应进入头部的脚本。我认为这个 Assetic 模块可以解决这个问题。这是我的推断:
应用程序配置
/**
* Assetic
*/
'assetic_configuration' => array(
'buildOnRequest' => true,
'cacheEnabled' => false,
'webPath' => realpath('public/assets'),
'basePath' => 'assets',
'default' => array(
'assets' => array(
'@base_css',
'@head_js',
),
'options' => array(
'mixin' => true,
),
),
'modules' => array(
'application' => array(
# module root path for yout css and js files
'root_path' => __DIR__ . '/../assets',
# collection of assets
'collections' => array(
'base_css' => array(
'assets' => array(
'css/*.css',
),
'filters' => array(),
'options' => array(),
),
'head_js' => array(
'assets' => array(
'js/*.js',
),
'filters' => array(),
),
'base_images' => array(
'assets'=> array(
'images/*.png',
),
'options' => array(
'move_raw' => true,
)
),
),
),
),
),
然后在我的 Foo 模块中...
Foo 模块配置
/**
* Assetic
*/
'assetic_configuration' => array(
'default' => array(
'assets' => array(
'@base_css',
'@head_js',
),
'options' => array(
'mixin' => true,
),
),
'modules' => array(
'foo' => array(
# module root path for yout css and js files
'root_path' => __DIR__ . '/../assets',
# collection of assets
'collections' => array(
'base_css' => array(
'assets' => array(
'css/*.css'
),
'filters' => array(),
'options' => array(),
),
'head_js' => array(
'assets' => array(
'js/*.js' // relative to 'root_path'
),
'filters' => array(),
'options' => array(),
),
'base_images' => array(
'assets'=> array(
'images/*.png'
),
'options' => array(
'move_raw' => true,
)
),
),
),
),
),
不幸的是,通过这个配置,只有 Foo 模块的 javascript 才能进入 head_js.js。我感觉就像米尔顿的那个模因,“我被告知会有 Assets 合并!” :)
感谢您提供的任何帮助。
谢谢!
最佳答案
好的 - 我已经弄清楚了。希望有一天这对其他人有帮助。我上面提到的配置键并非不准确,但是,当考虑到 secret 的未记录功能时,它们的设计不正确;必须破解源代码才能了解到在资源包中包含“head”一词实际上会将其自动加载到头部。最终,这是一个不错的功能,但当您没有意识到时,这确实是一个令人头疼的功能。
关于php - 将 HeadScript javascript 与 widmogrod/zf2-assetic-module 和多个模块中的 js 结合起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18343898/
我正在使用 ZF2 并面临一个奇怪的行为。当我使用 headScript 附加或前置一些 Javascript 文件时,该文件被包含两次。 inlineScript 也是如此。 这是我使用 headS
我正在使用 Zend_View_Helper_HeadScript 在 中添加 JavaScript 代码标签。 $view->headScript()->appendScript($javascr
有时 javascript 代码需要来自服务器的一些数据(例如 JS 和 C# 之间共享的常量或配置)。我不想通过 Ajax 提取这些数据。我想将此数据呈现到服务器上的 html 页面中。 比方说,我
我试图找出是否有任何类似于 Zend 中的 codeigniter 的东西,我可以在其中将文件附加到标题区域(如 CSS)或页脚区域(如 javascript)。问题是我找不到任何东西,这意味着要么不
我在尝试使用 Zend 的 headScript()->appendFile('file name') 附加 javascript 文件时遇到问题。我的布局设置如下: headScript()
我有一个案例,我需要将 Controller 中的 Javascript 添加到已经有 HeadScript() 的布局中; 如何从 Controller 做到这一点? 例如:$this->view-
我正在开发一个新的 zend 框架应用程序,当我刚刚为我的 layout.phtml 文件和 Bootstrap _initScript 方法硬编码 headScript 部分时,在没有加载脚本后查看
我想将一些脚本添加到 的末尾页面的内容,以及我需要在 中包含的一些内容。我想知道是否有更优雅的方法将某些脚本添加到 以及 中的某些内容使用段或类似的东西。假设我有两个脚本将进入正文: $this
遇到了一些障碍,我找不到任何支持文档。我的用例相当简单。 Application 模块具有应进入头部的 javascript,而我的其他模块之一 Foo 也具有应进入头部的脚本。我认为这个 Asset
遇到了一些障碍,我找不到任何支持文档。我的用例相当简单。 Application 模块有应该进入头部的 javascript,而我的其他模块之一 Foo 也有应该进入头部的脚本。我认为这个 Asset
我是一名优秀的程序员,十分优秀!