chrome无法打断点,也看到了同样问题的两个提问,我这也无法打断点,行号是灰色的点不动
来源:5-6 Popular(最热)模块的自定义标签功能实现-1
Leonard_
2018-07-03
我在loadData方法加了debugger,停在了第一行import 语句
import React,{Component} from 'react'
import {
View,
Text,
StyleSheet,
ListView,
RefreshControl
} from 'react-native'
import ScrollableTabView,{ScrollableTabBar} from 'react-native-scrollable-tab-view'
import NavigationBar from '../common/NavigationBar'
import DataRepository from '../expand/dao/DataRepository'
import RepositoryCell from '../common/RepositoryCell'
const URL='https://api.github.com/search/repositories?q='
const QUERY_STR='&sort=stars'
export default class PopularPage extends Component{
render(){
return(
<View style={styles.container}>
<NavigationBar
title='最热'
statusBar={{
backgroundColor:'#2196F3'
}}
/>
<ScrollableTabView
tabBarInactiveTextColor='mintcream'
tabBarAtiveTextColor='white'
tabBarBackgroundColor='#2196F3'
tabBarUnderlineStyle={{backgroundColor:'#e7e7e7',height:2}}
renderTabBar={()=><ScrollableTabBar/>}
>
<PopularTab tabLabel='Java'/>
<PopularTab tabLabel='iOS'/>
<PopularTab tabLabel='Android'/>
<PopularTab tabLabel='JavaScrip'/>
</ScrollableTabView>
</View>
)
}
}
class PopularTab extends Component{
constructor(props){
super(props)
this.dataRepository=new DataRepository();
this.state={
isLoading:false,
result:'',
dataSource :new ListView.DataSource({rowHasChanged:(r1,r2)=>r1!==r2})
}
}
componentDidMount() {
this.loadData()
}
loadData(){
debugger
this.setState({
isLoading:true,
})
let url=URL+this.props.tabLabel+QUERY_STR
this.dataRepository.fetchNetRepository(url)
.then(result=>{
this.setState({
dataSource:this.state.dataSource.cloneWithRows(result.items),
isLoading:false,
})
})
.catch(error=>{
this.setState({
result:JSON.stringify(error)
})
})
}
renderRow(data){
return <RepositoryCell data={data}/>
}
render(){
return(
<View style={{flex:1}}>
<ListView
dataSource={this.state.dataSource}
renderRow={data=>this.renderRow(data)}
refreshControl={
<RefreshControl
refreshing={this.state.isLoading}
onRefresh={()=>this.loadData()}
colors={['#2196F3']}//android下
tintColor={'#2196F3'}//iOS下
title={'Loading...'}
titleColor={'#2196F3'}
/>
}
/>
</View>
)
}
}
const styles=StyleSheet.create({
container:{
flex:1
},
tips:{
fontSize:29,
}
})
1回答
-
可以通过debugger标识符来进行调试:
render() { debugger;//debug模式下程序执行到这里会暂停 const Root=<SafeAreaViewPlus topColor={this.state.theme.themeColor} bottomInset={false}> ...
另外也可以尝试:初始化模拟器 、清除chrome缓存 、重启电脑来解决;
012018-07-09
相似问题
回答 1
回答 1