didi / mand-mobile

💰 A mobile UI toolkit, based on Vue.js 2, designed for financial scenarios.
https://didi.github.io/mand-mobile
Apache License 2.0
3.46k stars 772 forks source link

全局导入文档问题 Uncaught ReferenceError: mandMobile is not defined #259

Closed de1ck closed 5 years ago

de1ck commented 5 years ago

docs

import Vue from 'vue'
import mandMobile from 'mand-mobile'
import 'mand-mobile/lib/mand-mobile.css'

Vue.use(mandMobile)

正确的用法

import mandMobile from 'mand-mobile/lib/mand-mobile.esm'
import 'mand-mobile/lib/mand-mobile.css'
Vue.use(mandMobile)

mand-mobile 默认是UMD模块,而例子中使用的是ESM

xxyan0205 commented 5 years ago

哪个版本?

de1ck commented 5 years ago

@xxyan0205 2.x rc4 最新版

xxyan0205 commented 5 years ago

@xxyan0205 2.x rc4 最新版

package.json配置了mainmodule两个字段,构建工具会自动选择合适的bundle。当然两个版本都不应该出现Uncaught ReferenceError: mandMobile is not defined的问题

{
  "main": "lib/mand-mobile.umd.js",
  "module": "lib/mand-mobile.esm.js"
}

Edit Mand Mobile Bundles

de1ck commented 5 years ago

@xxyan0205 2.x rc4 最新版

package.json配置了mainmodule两个字段,构建工具会自动选择合适的bundle。当然两个版本都不应该出现Uncaught ReferenceError: mandMobile is not defined的问题

{
  "main": "lib/mand-mobile.umd.js",
  "module": "lib/mand-mobile.esm.js"
}

Edit Mand Mobile Bundles

babel-plugin-import 配置导致的,我的问题. 项目中刚引入storybook 开发UI,忘记项目之前使用了babel-plugin-import