我试图在我的本机应用程序中自动播放youtube嵌入式视频.
这是我的代码,
render() {
const { data } = this.props;
const { loading } = this.state;
return (
<View>
<CloseButton onTrigger={this.closeModal.bind(this)} />
<PlayIcon onTrigger={this.playVideo} />
<Image source={{uri:data.src}} resize='contain' style={{height:250}} />
<Image
source={require('../../assets/img/grediant.png')}
resizeMode='cover' style={styles.gradientImage} />
<ContentWidget style={styles.infoContentTwo}>
<MyAppText style={{color:'white'}}>{data.title}</MyAppText>
</ContentWidget>
{this.state.openVideo && <View style={styles.webViewStyle}>
<WebView style={{height:250}} source={{uri:`${data.video}?autoplay=1`}} fullScreen={true} />
</View>}
{loading && <Spinner />}
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我有一个playIcon自定义按钮,如果我点击该按钮,那么youtube视频应播放.我不知道代码中哪里出错了.
如何在React Native中的密码输入字段中停止输入空格?
password 可能是任何角色,包括空间.
我试过这个:validator.js
const extract = (str, pattern) => (str.match(pattern) || []).pop() || '';
export function removeWhiteSpace(str) {
return extract(str, '/^\S*$/;');
}
Run Code Online (Sandbox Code Playgroud)
login.js
passwordHandle(value){
this.setState({
password:removeWhiteSpace(value)
})
console.log(removeWhiteSpace(value))
}
Run Code Online (Sandbox Code Playgroud)
渲染()
<View style={{paddingBottom:25}}>
<TextField
label='Password'
type='password'
value={password}
error={errors.password}
icon
onChange={this.passwordHandle}/>
<Image
source={require('../../../assets/img/lock.png')}
style={styles.icon} />
</View>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.它只执行'/ ^\S*$ /;' 来自removeWhiteSpace.
参考错误:未定义窗口。当我通过 jest 运行 npm test 进行单元测试时出现此错误。错误来自以下代码导出功能。任何人遇到这种类型的错误并解决了它?
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../modules/rootReducer';
export function injectAsyncReducers(asyncReducers) {
const injectReducers = Object.keys(asyncReducers).reduce((all, item) => {
if (store.asyncReducers[item]) {
delete all[item];
}
return all;
}, asyncReducers);
store.asyncReducers = Object.assign({}, store.asyncReducers, injectReducers);
replaceReducers(rootReducer);
}
Run Code Online (Sandbox Code Playgroud)