babel-plugin-component icon indicating copy to clipboard operation
babel-plugin-component copied to clipboard

多组件引入的时候报错

Open mino01x opened this issue 6 years ago • 8 comments

[
  ["component", {"libraryName": "library1", "styleLibraryName": "styles"}],
  ["component", {"libraryName": "library2", "styleLibraryName": "styles"}]
]
import { component } from "library2"

// 会报 library1/lib/component 找不到

mino01x avatar Mar 27 '18 15:03 mino01x

兄弟,这个问题解决了吗

yoyou avatar Mar 30 '18 03:03 yoyou

我分析了下, 示例是错误的。多个lib的时候,引用方式应该是 这个形式: ["component", [{ "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }, { "libraryName": "mint-ui", "style": true }]],

tengmaoqing avatar Apr 27 '18 10:04 tengmaoqing

@tengmaoqing 也是有问题的 https://github.com/nuxt/nuxt.js/issues/1603

yoyo837 avatar Jun 08 '18 09:06 yoyo837

我分析了下, 示例是错误的。多个lib的时候,引用方式应该是 这个形式: ["component", [{ "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }, { "libraryName": "mint-ui", "style": true }]],

这种方式我这可以,之前是两个对象并列,有点第二个把第一个覆盖了的意思,现在放到一个数组里,就成了共存的了。。。以上纯属个人瞎猜,还是滚去看下源码把。。。

webuy-front avatar Jan 16 '19 04:01 webuy-front

我分析了下, 示例是错误的。多个lib的时候,引用方式应该是 这个形式: ["component", [{ "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }, { "libraryName": "mint-ui", "style": true }]],

这种方式可以解决 +1

ZinLiao avatar Apr 03 '19 09:04 ZinLiao

@ZinLiao 我这里不行,试过了

yoyo837 avatar Apr 03 '19 09:04 yoyo837

@yoyo837 你的貌似是nuxt引起的吧,试下把nuxt的后端渲染关掉

ZinLiao avatar Apr 03 '19 09:04 ZinLiao

Multiple Modules

{
  "plugins": [
    [
      "component",
      [
        {
          "libraryName": "antd",
          "style": true
        },
        {
          "libraryName": "test-module",
          "style": true
        },
        // ...
      ]
    ]
  }

g8up avatar Jul 01 '19 03:07 g8up