我正在尝试将 express 导入项目,在开发过程中,它停止工作,我重置了配置等。无法使其工作,无法导入任何模块。
npx tsc src/server.ts
src/server.ts:1:8 - error TS1259: Module '"/home/fpc-ubut/Git/nlw2/server/node_modules/@types/express/index"' can only be default-imported using the 'esModuleInterop' flag
1 import express from 'express';
Run Code Online (Sandbox Code Playgroud)
src/database/migrations/00_create_users.ts:1:8 - error TS1259: Module '"/home/fpc-ubut/Git/nlw2/server/node_modules/knex/types/index"' can only be default-imported using the 'esModuleInterop' flag
1 import Knex from 'knex'
Run Code Online (Sandbox Code Playgroud)
src/server.ts:1:8 - error TS1259: Module '"path"' can only be default-imported using the 'esModuleInterop' flag
1 import path from 'path'
Run Code Online (Sandbox Code Playgroud)
环境操作系统:Ubuntu 20.04.1 LTS
节点:v12.18.1
包:
"@types/express": "^4.17.6",
"@types/node": "^14.0.27",
"ts-node": "^8.10.2",
"ts-node-dev": "^1.0.0-pre.44",
"typescript": "^3.9.3"
"express": "^4.17.1", …Run Code Online (Sandbox Code Playgroud) 我正在制作一个菜单来更改Google Maps API的类型,但是按下的状态无法按我预期的方式工作。需要注意的是文本组件内部的状态没有被重新渲染后this.state.pressed通过功能改变setPressedState,它不包含在组件上重新绘制MapMenu使用后组件getPressed。
注意:警报显示按下的状态正在更改。
class MapMenu extends Component{
constructor(props){
super(props);
this.state = {
pressed: 'standard'
}
}
setPressedState(press){
this.state.pressed = press;
Alert.alert(this.state.pressed)
}
getPressed(){
return(this.state.pressed);
}
render(){
return(
<View style={styles.container}>
<View style={{backgroundColor: 'red'}}><Text>{this.state.pressed}</Text></View>
<TouchableOpacity style={styles.button}
onPress={() => this.setPressedState('standart')}
>
<Text>Mapa</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button}
onPress={() => this.setPressedState('hybrid')}
>
<Text>Hibrido</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button}
onPress={() => this.setPressedState('satellite')}
>
<Text>Satellite</Text>
</TouchableOpacity>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)