没有Vue.use的Vue.js加载组件主题

时间:2019-06-12 07:57:37

标签: vue.js vue-select

我正在使用Cool-Select,并且需要以下代码来加载其主题:

import VueSelect from 'vue-cool-select'
Vue.use(VueSelect, {
  theme:'material-design'
})

问题是我不想为了使用主题就必须导入整个vue代码。而且,这些组件在没有主题导入的情况下仍可以运行。只是缺少CSS。

是否可以像这样在components部分中本地导入主题?

import { CoolSelect } from 'vue-cool-select'      
components:{
        CoolSelect,
        // import theme here
 },

1 个答案:

答案 0 :(得分:0)

VueSelect是一个插件,即它具有install method,当提供给Vue.use时将被调用。除了loads styles that are specific to this component之外,这不会影响应用程序。

由于样式不是从软件包中导出的,而是仅在插件安装时加载的,因此这是CoolSelect组件可以在不分叉软件包的情况下加载其样式的唯一方法:

Vue.use(VueSelect, {
  theme:'material-design'
})