Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webview 添加header #51

Open
wuyunqiang opened this issue May 23, 2018 · 0 comments
Open

webview 添加header #51

wuyunqiang opened this issue May 23, 2018 · 0 comments
Labels

Comments

@wuyunqiang
Copy link
Owner

wuyunqiang commented May 23, 2018

 react: ^16.3.0-alpha.1 => 16.3.1
  react-native: ^0.55.4 => 0.55.4
  constructor(props){
    super(props);
      this.header = { //header中不能有"_"
          'xxxxx':'testing', //right
          'xxx-xxx':'native', //right
          'xxx_xxx':'native', //fail
      };
      this.webviewParams = {};
  }
    <WebView
              nativeConfig={
                  {
                      props: {
                          backgroundColor: '#ffffff',
                          flex: 1,
                          justifyContent:'center',
                          alignItems: 'center',
                      }
                  }
              }
              userAgent='MyApp'
              ref = {(webview)=>{this.web = webview}}
              style={{width:'100%',height:'100%',justifyContent:'center', alignItems: 'center'}}
              source={{uri:this.state.destinationUrl,headers:this.header}}
              onLoadStart={this.onLoadStart}
              // domStorageEnabled={true}
              // mixedContentMode={'always'}//指定混合内容模式。即WebView是否应该允许安全链接(https)页面中加载非安全链接(http)的内容,never,always,compatibility
              // onLoadEnd = {this.LoadEnd}//加载成功或者失败都会回调
              onError = {this.isConnNet}
              // scalesPageToFit = {true}
              // javaScriptEnabled = {true}//指定WebView中是否启用JavaScript
              onNavigationStateChange={(e) => {
                  this.onNavigationStateChange(e)//可以获取标题 url 等信息
              }} 
              startInLoadingState={true} //强制WebView在第一次加载时先显示loading视图
              // bounces={true}//指定滑动到边缘后是否有回弹效果。
              // scrollEnabled={true}//是否启用滚动
              renderLoading={this.renderLoad}//返回一个加载指示器
              renderError={(e) => {
                  return <View/>;
              }}
          />

header中是以key:value的形式存在的并且,key中不能有"_"。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant