首页 > 解决方案 > React Native Chrome 自定义选项卡不起作用

问题描述

我想react-native-custom-tabs在我的项目中添加,但问题是它正在显示

无法读取openURL未定义的属性。

import CustomTabs from 'react-native-custom-tabs';

class HomeScreen extends Component {

  constructor(props) {
    super(props);
    this.state = {
      images: []
    };
    this.onPressListener = this.onPressListener.bind(this);
  }

  async onPressListener(event) {
    try {
      const url = 'https://www.google.com';
      CustomTabs.openURL(url);
    } catch (error) {
      Alert.alert(error.message)
    }
  }
}

我使用 yarn add react-native-custom-tabs 安装它,然后我将它与 react-native 链接 react-native-custom-tabs 链接

标签: javascriptreact-native

解决方案


尝试导入 likeimport {CustomTabs} from 'react-native-custom-tabs';而不是import CustomTabs from 'react-native-custom-tabs';

希望能帮助到你。随时怀疑


推荐阅读