Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引入 loadCss #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

引入 loadCss #78

wants to merge 1 commit into from

Conversation

xiajian2019
Copy link

引入 loadCss 方法方法是为了可以异步加载 样式:

使用场景,例如在迁移 vant ui 组件到 godspen 体系里的时候,可能一个页面的会引入很多 vant 的组件,假如每个组件都依赖 vant 的 icon,通过godspen 原有将样式编译到组件的 js 中,就会存在重复引入相同的样式,导致页面加载的总体的组件体积变大,通过 loadCss 异步加载的样式的方式,可以方便解决这个问题。

其使用方式和 loadJs 类似,代码结构也类似。

import { Util } from 'godspen-lib'
export default {
  mounted: async function () {
    await Util.loadCss('https://cdn.bootcss.com/echarts/4.0.3/echarts.min.css')
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant