問題描述我正在用dva,antdesign和react-intl框架開發(fā)一個單頁應(yīng)用程序,并且使用react-intl實現(xiàn)國際化。我在最外層的index.js用 <IntlProvider>將所有的組件都包裹起來,這樣所有的子組件都能訪問到intl對象。問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法絕大部分頁面和組件都工作正常,但是antdesign的Modal所顯示的內(nèi)容,用react-intl的<FormattedMessage id="message.id"/>之后報錯,錯誤信息是:[React Intl] Could not find required intl object. <IntlProvider> needs to exist in the component ancestry.我通過Chrome的React插件觀察了組件的結(jié)構(gòu),出現(xiàn)此問題的原因是Model組件是寫在最外面(和App平級的)的這樣就不是<IntlProvider>的子組件了。我不想在每個用到Modal的組件或者頁面里再次寫一遍<IntlProvider>,請問有什么好的解決辦法?
antdesign的modal組件無法訪問IntlProvider,如何解決?
米琪卡哇伊
2018-10-24 11:19:05
