You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
antd通过上述方法能正常引入且无报错
antd-mobile报错 Uncaught ReferenceError: mobile is not defined
Environment
Info
antd
2.3.2
React
16.13.1
System
MAC OS Catalina
Browser
Chrome
antd成功引入,在控制台能console出window.antd,无报错,然而antd-mobile换成CDN的话,console.log(window.antd-mobile)会出现Uncaught ReferenceError: mobile is not defined错误,经查看window对象,是已经定义了antd-mobile的全局变量的,通过window["antd-mobile"]是可以看到对应的方法,但是window.antd-mobile不行,貌似默认是window.antd-mobile?怎么解决呢?
上面的网址,是已经在index.html引入了antd-mobile,但是webpack打包没有exclude的例子,所以页面能正常显示哈。进去后进入控制台,打印出window对象的话,是可以看到window里有antd-mobile对象的。但是如果我webpack打包exclude了antd-mobile,就会报跟window.antd-mobile一样的Uncaught ReferenceError: mobile is not defined 错误
Reproduction link
http://106.55.10.117/tlink_loan/RegistPage
Steps to reproduce
在create-react-app脚手架,成功引入antd和antd-mobile后,将两者都换成CDN形式引入,模仿"通过CDN引入antd"的步骤来引入antd-mobile:
What is expected?
antd和antd-mobile都能正常引入,无报错且页面正常
What is actually happening?
antd通过上述方法能正常引入且无报错
antd-mobile报错
Uncaught ReferenceError: mobile is not defined
antd成功引入,在控制台能console出
window.antd
,无报错,然而antd-mobile换成CDN的话,console.log(window.antd-mobile)
会出现Uncaught ReferenceError: mobile is not defined
错误,经查看window对象,是已经定义了antd-mobile的全局变量的,通过window["antd-mobile"]
是可以看到对应的方法,但是window.antd-mobile
不行,貌似默认是window.antd-mobile
?怎么解决呢?上面的网址,是已经在index.html引入了antd-mobile,但是webpack打包没有exclude的例子,所以页面能正常显示哈。进去后进入控制台,打印出window对象的话,是可以看到window里有antd-mobile对象的。但是如果我webpack打包exclude了antd-mobile,就会报跟
window.antd-mobile
一样的Uncaught ReferenceError: mobile is not defined
错误应该是语法的问题,js里如果window.antd-mobile的话,-后的字符会undefined,但是antd-mobile cdn引入后默认是antd-mobile这个对象,需要通过window["antd-mobile"]才能调用到这个对象,这怎么解决呢?
The text was updated successfully, but these errors were encountered: