react native 填坑之路 (Search Paths / WebView)
xcode build err
'React/RCTAssert.h' file not found
处理方式:
点击项目图标, 选择 Build Settings, 找到 "Search Paths", "Header Search Paths", 修改
$(SRCROOT)/../../../react-native/React
为
$(SRCROOT)/../react-native/React
react-native中WebView的问题 #原文链接
<ScrollView> <View></View>
<View style={{height: this.state.height}}>
<WebView
automaticallyAdjustContentInsets={false}
javaScriptEnabled={true}
domStorageEnabled={true}
scalesPageToFit={Platform.OS!=='ios'}
onMessage={this.onMessage}
style={[{flex:1}]}
injectedJavaScript={injectScript}
source={{html:`<!DOCTYPE html><body>${this.state.html}</body></html>`,baseUrl:''}}
/>
</View>
</ScrollView>
const injectScript = ` // 解决外部高度显示不正确的问题 (function () { var height = null; function changeHeight() { if (document.body.scrollHeight != height) { height = document.body.scrollHeight; if (window.postMessage) { window.postMessage(JSON.stringify({ type: 'setHeight', height: height, })) } } } setInterval(changeHeight, 100); }()); `;
onMessage=(event)=>{ try { const action = JSON.parse(event.nativeEvent.data); if (action.type === 'setHeight' && action.height > 0) { this.setState({ height: action.height }); } } catch (error) { // pass } }
'config.h' file not found
cd node_modules/react-native/third-party/glog-0.3.4
../../scripts/ios-configure-glog.sh
浙公网安备 33010602011771号