当我console.log()在onEnd视频组件的功能内部时,它会在页面加载时立即被调用.该console.log()从onPress的ThouchableHighlight也被称为在同一时间.我使用Actions.videoPlayer()repo react-native-router-flux来点击此视频的缩略图进入此页面.
render() {
let video = require('../videos/HISTORISCHETUIN.mp4');
return (
<View>
<TouchableHighlight onPress={console.log("Test")}>
<View>
<Video source={video} // Can be a URL or a local file.
ref={ref => this.player = ref} // Store reference
rate={1.0} // 0 is paused, 1 is normal.
volume={1.0} // 0 is muted, 1 is normal.
muted={false} // Mutes the audio entirely.
paused={true} // Pauses playback entirely.
resizeMode="stretch" // Fill the whole screen at aspect ratio.
repeat={true} // Repeat forever.
playInBackground={false} // Audio continues to play when app entering background.
playWhenInactive={false} // [iOS] Video continues to play when control or notification center are shown.
progressUpdateInterval={250.0} // [iOS] Interval to fire onProgress (default to ~250ms)
onLoadStart={this.loadStart} // Callback when video starts to load
onLoad={() => {
this.player.seek(30);
}} // Callback when video loads
onProgress={this.setTime} // Callback every ~250ms with currentTime
onEnd={console.log("Test")} // Callback when playback finishes
onError={this.videoError} // Callback when video cannot be loaded
style={styles.video} />
</View>
</TouchableHighlight>
</View>
)
Run Code Online (Sandbox Code Playgroud)
}
console.log()视频结束后为什么不拨打电话?当我按下视频时,它也没有做任何事情.
那是因为你需要将它包装在一个闭包中.
这段代码:
onEnd={console.log('123')}
Run Code Online (Sandbox Code Playgroud)
console.log当prop正在期望一个函数时,会立即执行渲染组件的时间.
要修复它,请使用:
onEnd={() => console.log('123')}
Run Code Online (Sandbox Code Playgroud)
在这里,你给道具一个它可以执行的功能,而不是结果console.log.
| 归档时间: |
|
| 查看次数: |
1055 次 |
| 最近记录: |