aro*_*hev 24
1)在全球范围内,可以借助AssetMananer的帮助.这有特殊选项$ forceCopy.
您可以使用组件将其设置为:
use Yii;
Yii::$app->assetManager->forceCopy = true;
Run Code Online (Sandbox Code Playgroud)
或者在应用程序配置中
'components' => [
'assetManager' => [
'class' => 'yii\web\AssetManager',
'forceCopy' => true,
],
],
Run Code Online (Sandbox Code Playgroud)
2)如果要在特定的AssetBundle中禁用缓存,请使用$ publishOptions属性:
public $sourcePath = '...' // In order to use $publishOptions you should specify correct source path.
public $publishOptions = [
'forceCopy' => true,
];
Run Code Online (Sandbox Code Playgroud)
或者,您可以使用bundles属性在选项1中指定此选项.例如:
'components' => [
'assetManager' => [
'class' => 'yii\web\AssetManager',
'forceCopy' => true,
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'forceCopy' => true,
],
],
],
],
Run Code Online (Sandbox Code Playgroud)
但是这个:
'forceCopy' => YII_DEBUG,
Run Code Online (Sandbox Code Playgroud)
更灵活,因为它仅在调试模式下禁用此资产包缓存,但允许在生产服务器上使用.YII_DEBUG是的web/index.php.
| 归档时间: |
|
| 查看次数: |
15382 次 |
| 最近记录: |