为什么在React Native中没有调用WebView.onLoadStart和onLoadEnd?

时间:2017-02-08 06:18:27

标签: react-native

我尝试过使用这样的元素:

                         <WebView
                            source={{ uri: contentURL }}
                            startInLoadingState={true}
                            style={styles.articleOnWeb.webView}>
                            onLoadStart={function () {
                                ToastAndroid.show("onLoadStart", ToastAndroid.SHORT)
                                console.log("onLoadStart")
                                const nextState = Immutable.Map(thisComponent.state).toJS()
                                nextState.articleOnWebLoadingProgress = 0.5
                                thisComponent.setState(nextState)
                            }}
                            onLoadEnd={function () {
                                ToastAndroid.show("onLoadEnd", ToastAndroid.SHORT)
                                console.log("onLoadEnd")
                                const nextState = Immutable.Map(thisComponent.state).toJS()
                                nextState.articleOnWebLoadingProgress = 1
                                thisComponent.setState(nextState)
                                setTimeout(()=> {
                                    const nextState = Immutable.Map(thisComponent.state).toJS()
                                    nextState.articleOnWebIsLoaded = true
                                    thisComponent.setState(nextState)
                                }, 1000)
                            }}
                        </WebView>

0 个答案:

没有答案