如何在ExtJs 5中添加自定义CSS文件?

时间:2015-04-01 16:07:56

标签: css extjs extjs5

在ExtJs 4中,我包含了一个这样的自定义css:

<!-- <x-compile> -->
    <!-- <x-bootstrap> -->
        <link rel="stylesheet" href="bootstrap.css">
        <script src="ext/ext-dev.js"></script>
        <script src="bootstrap.js"></script>
    <!-- </x-bootstrap> -->
    <script src="app.js"></script>
<!-- </x-compile> -->
<link rel="stylesheet" href="/custom/css.css" type="text/css" charset="utf-8" />

<x-compile>部分之后链接到CSS的事实使得它稍后加载,因此custom.css中的规则覆盖了编译的extjs主题css中的规则。

在ExtJs 5.0中,这不再起作用了。尽管在microloader之后包含了自定义css,但主题css在custom.css之后加载:

<script id="microloader" type="text/javascript" src="bootstrap.js"></script>
<link rel="stylesheet" href="/custom/css.css" type="text/css" charset="utf-8" />

如何实现最后加载custom.css以覆盖ExtJs css文件中的某些规则?

1 个答案:

答案 0 :(得分:1)

打开app.json并查找css属性。在那里添加您的文件,Sencha CMD将它与框架CSS捆绑在一起。默认值如下所示:

/**
 * List of all CSS assets in the right inclusion order.
 *
 * Each item is an object with the following format:
 *
 *      {
 *          // Path to file. If the file is local this must be a relative path from
 *          // this app.json file.
 *          //
 *          "path": "path/to/stylesheet.css",   // REQUIRED
 *
 *          // Specify as true if this file is remote and should not be copied into the
 *          // build folder. Defaults to false for a local file which will be copied.
 *          //
 *          "remote": false,    // OPTIONAL
 *
 *          // If not specified, this file will only be loaded once, and cached inside
 *          // localStorage until this value is changed. You can specify:
 *          //
 *          //   - "delta" to enable over-the-air delta update for this file
 *          //   - "full" means full update will be made when this file changes
 *          //
 *          "update": ""      // OPTIONAL
 *      }
 */
"css": [
    {
        "path": "bootstrap.css",
        "bootstrap": true
    }
],