React native 反应本族语:can';找不到可变文档
我正在尝试将EventListner添加到文档对象,但由于React native 反应本族语:can';找不到可变文档,react-native,React Native,我正在尝试将EventListner添加到文档对象,但由于找不到变量文档,因此出现错误。 下面是我的代码 import * as React from 'react'; import { Easing, Text, View, StyleSheet , Button , TextInput , TouchableOpacity , TouchableWithoutFeedback, Animated} from 'react-native'; import DateTimePicker from
找不到变量文档
,因此出现错误。
下面是我的代码
import * as React from 'react';
import { Easing, Text, View, StyleSheet , Button , TextInput , TouchableOpacity , TouchableWithoutFeedback, Animated} from 'react-native';
import DateTimePicker from "react-native-modal-datetime-picker";
import { Platform, StatusBar} from 'react-native';
import ReactDOM from 'react-dom';
// You can import from local files
// or any pure javascript modules available in npm
export default class App extends React.Component {
state = {
menuwidth: new Animated.Value(0)
}
showmenu = () => {
Animated.timing(this.state.menuwidth,{
toValue: 1,
duration: 550,
easing: Easing.linear
}).start();
}
hidemenu = () => {
}
componentWillMount() {
document.addEventListner('click',this.clickoutside,false)
}
componentWillUnMount(){
document.removeEventListner('click',this.clickoutside,false)
}
render() {
const menuwidth_interpole = this.state.menuwidth.interpolate({
inputRange: [0,1],
outputRange: ['-50%','0%']
})
我错过什么了吗。我使用本教程来解决单击外部组件的问题。1)您拼写“Listener”错误。它应该是addEventListener和removeEventListener。2) 我认为您需要使用window.addEventListener而不是document。签出文档在React Native中是否有效?您不能在React Native中使用
文档
,您可以在菜单后面创建背景,然后按Background将其隐藏。