不变违规:requireNativeComponent:在 UIManager 中找不到 "RCTYouTube"
Invariant Violation: requireNativeComponent: "RCTYouTube" was not found in the UIManager
详情如下:-
我使用命令行 npx expo-cli init youtube
生成了我的 React Native Expo 项目
然后我参考了这个 link:- https://www.npmjs.com/package/react-native-youtube
我使用以下命令安装了 react-native-youtube 依赖项:- npm i react-native-youtube
我还从 https://developers.google.com/youtube/android/player/register
获得了我的官方 youtube API
在App.js文件中下面是写的代码
`import React from 'react'
import {View,StyleSheet,Text,SafeAreaView} from 'react-native'
import YouTube from 'react-native-youtube';
const App=()=>{
const linkTest="https://www.youtube.com/watch?v=aqz-KE-bpKQ"
return (
<SafeAreaView style={styles.container}>
<YouTube
apiKey="*******************"
videoId={linkTest} // The YouTube video ID
play // control playback of video with true/false
fullscreen // control whether the video should play in fullscreen or inline
loop // control whether the video should loop when ended
onReady={e => this.setState({ isReady: true })}
onChangeState={e => this.setState({ status: e.state })}
onChangeQuality={e => this.setState({ quality: e.quality })}
onError={e => this.setState({ error: e.error })}
style={{ alignSelf: 'stretch', height: 300 }}
/>
</SafeAreaView>
)
}
const styles= StyleSheet.create({
container:{ backgroundColor:"white", flex:1},
})
export default App
在此之后,在我的 cmd 中 运行 :- npm start
扫描二维码并在我的手机中打开我的 EXPO 应用程序中的应用程序
以下是我得到的错误截图
点击here查看大图:
点击here查看大图:
点击here查看大图:
下图是运行项目在android平台或手机上的截图:
点击here查看大图:
取模 'react-native-youtube' 不支持 youtube link。而不是那个使用
<WebView
style={ styles.styleCode }
javaScriptEnabled={true}
domStorageEnabled={true}
source={{uri: 'https://www.youtube.com/embed/dFKhWe2bBkM' }}
/>
从(分享 > 嵌入)找到 YouTube 网址。
详情如下:-
我使用命令行 npx expo-cli init youtube
生成了我的 React Native Expo 项目
然后我参考了这个 link:- https://www.npmjs.com/package/react-native-youtube
我使用以下命令安装了 react-native-youtube 依赖项:- npm i react-native-youtube
我还从 https://developers.google.com/youtube/android/player/register
在App.js文件中下面是写的代码
`import React from 'react'
import {View,StyleSheet,Text,SafeAreaView} from 'react-native'
import YouTube from 'react-native-youtube';
const App=()=>{
const linkTest="https://www.youtube.com/watch?v=aqz-KE-bpKQ"
return (
<SafeAreaView style={styles.container}>
<YouTube
apiKey="*******************"
videoId={linkTest} // The YouTube video ID
play // control playback of video with true/false
fullscreen // control whether the video should play in fullscreen or inline
loop // control whether the video should loop when ended
onReady={e => this.setState({ isReady: true })}
onChangeState={e => this.setState({ status: e.state })}
onChangeQuality={e => this.setState({ quality: e.quality })}
onError={e => this.setState({ error: e.error })}
style={{ alignSelf: 'stretch', height: 300 }}
/>
</SafeAreaView>
)
}
const styles= StyleSheet.create({
container:{ backgroundColor:"white", flex:1},
})
export default App
在此之后,在我的 cmd 中 运行 :- npm start
扫描二维码并在我的手机中打开我的 EXPO 应用程序中的应用程序
以下是我得到的错误截图
点击here查看大图:
点击here查看大图:
点击here查看大图:
下图是运行项目在android平台或手机上的截图:
点击here查看大图:
取模 'react-native-youtube' 不支持 youtube link。而不是那个使用
<WebView
style={ styles.styleCode }
javaScriptEnabled={true}
domStorageEnabled={true}
source={{uri: 'https://www.youtube.com/embed/dFKhWe2bBkM' }}
/>
从(分享 > 嵌入)找到 YouTube 网址。