css - Yii2:重载扩展的CSS
问题描述
我正在使用扩展dmstr/yii2-cookie-consent来获得 cookie 同意,并且我想修改扩展的 CSS。扩展中的 CSS 作为 AssetBundle 包含在内。
以下是我的问题:
- 如何在 deleopment 期间用我的 CSS 重载扩展的 CSS(没有 AssetBundle,没有 caing)?
- 如何在生产中使用我的 CSS,即是否可以永久覆盖扩展的 CSS(当然使用缓存)?
解决方案
在开发过程中,您可以使用
$this->registerCss(".your-css {}")
用于原型制作
上线时,您可以使用依赖注入重载扩展资产包
'assetManager' => [
'bundles' => [
'dmstr\cookieconsent\assets\CookieConsentAsset' => [
'sourcePath' => '/path/to/your/source/path',
'css' => [
'css/yourstyles.css'
]
]
]
]
请记住,该包提供了根据应用程序环境加载资产的功能。在生产模式下,会加载 css 的压缩版本。
https://github.com/dmstr/yii2-cookie-consent/blob/master/src/assets/CookieConsentAsset.php#L20
推荐阅读
- javascript - 应用于行名的数据表内的回调函数不起作用
- python - 在Python中将矩阵的列乘以不同的数字
- vim - 如何从我上次进入的位置打开文件
- pyinstaller - 执行 PyInstaller .exe 文件时出现 OSError - “找不到或加载 spatialindex_c-64.dll”
- javascript - 我该如何解决这个错误?违规:组件`path`的视图配置getter回调必须是一个函数
- c++ - 如何在此 c++ 程序中给出大于 10000000 的值时解决段错误?
- grpc - 在谷歌 TTS(python)中使用同一客户端发送多个连续的“synthesize_speech”请求时出现“没有删除流”错误
- visual-studio-code - 如何在 vscode 中使用键盘查找/替换文件
- html - HTML 将 tabindex 与标签单击集成
- javascript - 按子对象中的键和/或值过滤对象数组