我是 Linux 用户。我尝试在 Web 浏览器中运行项目,但出现此错误:
Failed to compile.
./node_modules/@twotalltotems/react-native-otp-input/dist/index.js 133:20
Module parse failed: Unexpected token (133:20)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const { clearInputs, placeholderCharacter, placeholderTextColor } = this.props;
| const { color: defaultPlaceholderTextColor } = { ...defaultTextFieldStyle, ...codeInputFieldStyle };
> return (<View pointerEvents="none" key={index + "view"} testID="inputSlotView">
| <TextInput testID="textInput" underlineColorAndroid='rgba(0,0,0,0)' style={selectedIndex === index ? [defaultTextFieldStyle, codeInputFieldStyle, codeInputHighlightStyle] : [defaultTextFieldStyle, codeInputFieldStyle]} ref={ref => { this.fields[index] = ref; }} onChangeText={text => {
| this.handleChangeText(index, text);
我在 StackOverflow 上进行了搜索,找到了两个相关的答案来将其添加到 app.json:
"web": {
"build": {
"babel": {
"include": [
"native-base-shoutem-theme"
// "static-container" // another answer was
// I included both too but did not work
]
}
}
}
基于这里的解决方案https://github.com/expo/expo/issues/6157,我包括了这个包:
"include": ["@twotalltotems"]
但这给了我一个更复杂的错误