Disable zoom on web-view react-native?

后端 未结 7 1734
死守一世寂寞
死守一世寂寞 2021-01-01 12:22

How to disable zoom on react-native web-view,is there a property like hasZoom={false}(just an example) that can be included in the bel

7条回答
  •  暖寄归人
    2021-01-01 12:45

    Little hacky stuff but it works

    const INJECTEDJAVASCRIPT = 'const meta = document.createElement(\'meta\'); meta.setAttribute(\'content\', \'width=device-width, initial-scale=1, maximum-scale=0.99, user-scalable=0\'); meta.setAttribute(\'name\', \'viewport\'); document.getElementsByTagName(\'head\')[0].appendChild(meta); '
    
    
    
     {
              this.webView = webView
            }}
            originWhitelist={['*']}
            source={{ uri: url }}
            onNavigationStateChange={(navState) => {
              this.setState({
                backButtonEnabled: navState.canGoBack,
              })
            }}
          />
    

    Note initial-scale=1, maximum-scale=0.99, user-scalable=0

提交回复
热议问题