我最近开始转换我的本机应用程序并在Expo上运行,所以我可以在我的实际Android设备上测试它.我上面得到了这个错误.从那以后我使用Expo XDE运行我的应用程序.我也在Windows机器上运行.
完整的错误消息是:
] 1
我认为这与我的index.js有关,但在这里它是
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('projectTARA', () => 'App');
Run Code Online (Sandbox Code Playgroud) Py_Initialize:无法加载文件系统编解码器导入错误:没有名为'编码'的模块
当前线程0x00001558(最近一次调用)
python导致错误并在我卸载Anaconda后崩溃,我看了类似的帖子提到重置venv,但是我没有可用于Windows的命令.
有谁知道可能发生了什么?
我一直在网上搜索有关此错误的正确文档,但运气不佳,因为我无法确定此错误的原因。
这是我的整个代码:
第一部分:设置状态
export default class Whereto extends Component<{}> {
constructor(props) {
super(props);
this.state = {
latitude: null,
longitude: null,
location: null,
error: null,
markers:[],
};
}
Run Code Online (Sandbox Code Playgroud)
第二节组件没有挂载
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
error: null,
});
//geocode api
var myApiKey = '';
fetch('https://maps.googleapis.com/maps/api/geocode/json?address=' + position.coords.latitude + ',' + position.coords.longitude + '&key=' + myApiKey)
.then((response) => response.json())
.then((responseJson) => {
//console.log('ADDRESS GEOCODE is BACK!! => ' + JSON.stringify(responseJson));
var locationName = responseJson.results[0].address_components.filter(x => …
Run Code Online (Sandbox Code Playgroud) 我对此非常陌生,想知道如何正确地做到这一点.我的后端是一个django休息框架,我的前面是反应本机.我的后端有用户,我的应用程序需要令牌身份验证来识别用户.在探索了本机后,我知道我将需要使用fetch和post方法来访问api.
成功的身份验证应该让用户导航到主页面
这是我到目前为止:
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
TextInput,
KeyboardAvoidingView,
TouchableOpacity,
AsyncStorage,
} from 'react-native';
export default class Form extends Component<{}> {
constructor(props){
super(props);
this.state = {
username: "",
password: "",
}
}
componentDidMount(){
this._loadInitialState().done();
}
_loadInitialState= async() => {
var value = await AsyncStorage.getItem('user');
if (value !== null){
this.props.navigation.navigate('Main')
}
}
render(){
return(
//<KeyboardAvoidingView style={styles.wrapper}>
<View style={styles.container}>
<TextInput style={styles.boxInput} underlineColorAndroid='rgba(0,0,0,0)' placeholder="Username"
onChangeText={ (username) => this.setState({username}) }
underlineColorAndroid='transparent' onSubmitEditing={()=> this.password.focus()}/>
<TextInput style={styles.boxInput} underlineColorAndroid='rgba(0,0,0,0)' …
Run Code Online (Sandbox Code Playgroud)