当我运行"react-native run-android"时,它给了我错误:"无法连接到开发服务器......".
那么如何修复红色错误屏幕问题?任何建议表示赞赏!
我有一个FlatList包装在视图中.
<View {...this._panResponder.panHandlers}>
<FlatList .../>
</View>
Run Code Online (Sandbox Code Playgroud)
View是一个panResponder,所以如何在onPanResponderGrant触发器时禁用FlatList的滚动.
我有两个集合,文章和评论,评论中的文章是文章中_id的外键.
db.collection('article').aggregate([
{
$lookup: {
from: "comments",
localField: "_id",
foreignField: "articleId",
as: "comments"
}
},
...
])
Run Code Online (Sandbox Code Playgroud)
它不起作用,因为文章中的_id是一个ObjectID而articleId是字符串,那怎么办?
我有一个 flatList 视图,我希望它在数据更新时滚动到结束或滚动到索引(从服务器获取数据),我在 comoponentDidUpdate 中执行但它不起作用。现在当渲染完成时,listView 总是滚动到顶部而且我看不到最新加载的数据。所以有没有办法在渲染完成时捕获事件。
代码:
...
fetchData(){
fetch(url)
.then((res)=>{
this.setData({data:[...this.state.data, res.data]})
})
}
componentDidUpdate(){
this.refs.listView.scrollToEnd({animated:true})
}
render(){
return <FlatList ref='listView' data={this.state.data} onEndReached={()=>this.fetchData()}.../>
}
Run Code Online (Sandbox Code Playgroud) 我有两个表:用户信息和挑战
**userinfo**
username:'aa',nickname:'bb',...
**challenge**
username:'aa',win:1,loss:0,...
username:'aa',win:0,loss:1,...
username:'bb',win:1,loss:0,...
username:'bb',win:0,loss:1,...
Run Code Online (Sandbox Code Playgroud)
我正在尝试执行 mongodb 聚合,以对位于查找对象中的用户名进行分组,并根据位于challenge. 我的代码:
db.challenge.aggregate([
{$group : "$username",win: { $sum: "$win" }},loss: { $sum: "$loss" }}},
{$lookup: {from: "userinfo", localField: "username", foreignField: "username", as: "userinfo"}} ]);
Run Code Online (Sandbox Code Playgroud)
但在结果中 userinfo 返回一个空数组:
{ "_id" : "aa", win:12, loss:10,"userinfo" : [ ] }
{ "_id" : "bb", win:2, loss:5,"userinfo" : [ ] }
Run Code Online (Sandbox Code Playgroud)
mongo版本是3.4,那么我哪里出错了?
我有一个观点:
<View style={{height:this.state.pan.y}}></View>
Run Code Online (Sandbox Code Playgroud)
初始化状态:
...
constructor(props){
super(props);
this.state = {pan:new Animated.ValueXY()};
}
...
Run Code Online (Sandbox Code Playgroud)
它引发错误:
Failed prop type: Invalid prop `height` supplied to `View`.
Bad object: {
"height": 0
}
Run Code Online (Sandbox Code Playgroud)
但如果我设置:
<View style={{height:0}}></View>
Run Code Online (Sandbox Code Playgroud)
它为什么有效?