alinz / react-native-webview-bridge

React Native Webview with Javascript Bridge
MIT License
1.37k stars 491 forks source link

how to load js and css from html file #210

Open AlessandroAnnini opened 7 years ago

AlessandroAnnini commented 7 years ago

Hi, I have index.html, style.css and index.js all inside android/app/src/main/assets folder i'm setting up a webviewbridge like this:

<View style={container}>
  <WebViewBridge
    style={styles.wv}
    ref={wv => { this.webview = wv; }}
    source={{ uri: 'file:///android_asset/index.html' }}
    onMessage={this.onMessage}
    allowFileAccessFromFileURLs
    allowUniversalAccessFromFileURLs
    startInLoadingState
  />
</View>

then inside my index.html...

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=320, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="./style.css">
  </head>
  <body>
    <p id="elementOne">test</p>
    <script src="./index.js"></script>
  </body>
</html>

The paragraph called elementOne is rendered but the style.css and the index.js are not working at all.

Where I am wrong?

AlessandroAnnini commented 7 years ago

never mind, it was my fault!

AmandaDEn32 commented 5 years ago

same problem +1