站长资源网络编程

浅谈使用 Yii2 AssetBundle 中 $publishOptions 的正确姿势

整理:jimmy2026/8/3浏览2
简介本文介绍了使用 Yii2 AssetBundle 中 $publishOptions 的正确姿势,分享给大家,具体如下:官方文档:http://www.yiiframework.com/doc-2.0/guide-structure-assets.html 有兴趣的同学可以先看下官方原文档文档样

本文介绍了使用 Yii2 AssetBundle 中 $publishOptions 的正确姿势,分享给大家,具体如下:

官方文档:http://www.yiiframework.com/doc-2.0/guide-structure-assets.html

有兴趣的同学可以先看下官方原文档

文档样例代码

<"fontawesome" package.
 By specifying the only publishing option,
only the fonts and css subdirectories will be published.

为什么是错误的呢, 因为无法实现官网文档说明的 发布 fonts 和 css 两个目录的需求。

正确的写法如下:

//...
  public $publishOptions = [
    'only' => [
      'fonts/*',
      'css/*',
    ]
  ];

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。