我的aws-react-native应用程序在Android上运行良好(使用expo),但当我尝试在expo中使用"w“选项,然后在浏览器中运行它时,我得到以下错误页面。在我看来,一些库丢失了,或者类似的东西,有谁知道我可以尝试在web上提供它吗?
在Android上测试过,它工作得很好--问题似乎只发生在浏览器上,而且似乎与aws放大相关。
我的App.js导入:
import * as Localization from 'expo-localization';
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
// Necessary for "Auth" service
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';
import { Authenticator } from 'aws-amplify-react-native';
import awsconf from './source/aws-exports';
Auth.configure(awsconf);
Analytics.configure(awsconf);
//Necessary for Translation
console.log(Localization.locale);
import { I18n } from 'aws-amplify';
import dict from './source/translations';
I18n.setLanguage(Localization.locale);
I18n.putVocabularies(dict);
...
错误页:
×
ReferenceError: dict is not defined
Module.../../../../../../../../../../../environment/node_modules/aws-
amplify-react-native/dist/AmplifyI18n.js
node_modules/aws-amplify-react-native/dist/AmplifyI18n.js:14
11 | * and limitations under the License.
12 | */
13 |
> 14 | export default dict = {
15 | 'fr': {
16 | 'Loading...': "S'il vous plaît, attendez",
17 | 'Sign In': "Se connecter",
View compiled
__webpack_require__
/home/ubuntu/environment/webpack/bootstrap:724
721 | };
722 |
723 | // Execute the module function
> 724 | modules[moduleId].call(module.exports, module, module.exports,
hotCreateRequire(moduleId));
| ^ 725 |
726 | // Flag the module as loaded
727 | module.l = true;
View compiled
fn
/home/ubuntu/environment/webpack/bootstrap:101
98 | );
99 | hotCurrentParents = [];
100 | }
> 101 | return __webpack_require__(request);
| ^ 102 | };
发布于 2019-07-26 14:17:56
您需要安装和设置一些东西。
web
babel-preset-expo
react-native-web
,并将属性“”连接到app.json
中的expo.platforms阵列 "expo": {
"platforms": ["web"]
}
expo start
运行expo-cli
启动捆绑程序后,您可以按w键在浏览器中打开您的应用程序。注意:因为React-native
社区中的大多数库都不支持Web,所以它可能无法像RNW预期的那样工作。
发布于 2019-07-26 14:22:17
尝试从export default dict =
中删除dict =
,使其看起来如下所示:
export default {
'fr': {
...
https://stackoverflow.com/questions/57221163
复制相似问题