Commit 343abe50e77f89d469e470b04bf5e569b7baed33

Authored by jingsam
1 parent 49f124ae

add iview.install()

Showing 3 changed files with 17 additions and 6 deletions   Show diff stats
.babelrc 0 → 100644
  1 +{
  2 + "presets": ["es2015"],
  3 + "plugins": ["transform-runtime"],
  4 + "comments": false
  5 +}
... ...
build/webpack.config.js
... ... @@ -47,11 +47,6 @@ module.exports = {
47 47 js: 'babel'
48 48 }
49 49 },
50   - // 转es5
51   - babel: {
52   - presets: ['es2015'],
53   - plugins: ['transform-runtime']
54   - },
55 50 resolve: {
56 51 // require时省略的扩展名,如:require('module') 不需要module.js
57 52 extensions: ['', '.js', '.vue'],
... ...
src/index.js
... ... @@ -80,4 +80,15 @@ const iview = {
80 80 iSelect: Select
81 81 };
82 82  
83   -module.exports = iview;
  83 +const install = function (Vue) {
  84 + Object.keys(iview).forEach((key) => {
  85 + Vue.component(key, iview[name])
  86 + })
  87 +}
  88 +
  89 +// auto install
  90 +if (typeof window !== 'undefined' && window.Vue) {
  91 + install(window.Vue);
  92 +};
  93 +
  94 +module.exports = Object.assign(iview, {install});
... ...