首页 > 解决方案 > 有效的 CSS 未在 React Native WebView 的 HTML 中应用

问题描述

我有一个使用 html 和 css 制作的有效页面,当在浏览器上运行时,输出符合预期。我试图在 a 中呈现该 html 页面WebView,但没有应用 CSS 样式,我不明白为什么。这就是我的做法:

public render() {
    const css = `<style> /* ...all css styling goes here */ </style>`;
    const html = `<body> /* ...all html goes here */ </body>`;
    return (
        <WebView
            originWhitelist={["*"]}
            source={{html: css + html}}
        />
    );
}

我在这里想念什么?正如我所说,css 和 html 部分与页面中的完全一样,当我在浏览器中打开页面时,它工作得非常好。

标签: reactjsreact-nativewebviewandroid-webview

解决方案


推荐阅读