【发布时间】:2020-05-05 17:11:42
【问题描述】:
我正在处理我网站的条款和条件页面。我将实际文档作为 .docx 文件,但使用 Google Docs 我可以将其导出为 .html 文件。
生成的文件是它自己的独立 HTML 元素,带有 Google 加载的自定义样式表。它看起来像这样(总结):
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style type="text/css">
@import url('https://themes.googleusercontent.com/fonts/css?kit=fpjTOVmNbO4Lz34iLyptLUXza5VhXqVC6o75Eld_V98');.lst-kix_list_1-3>li:before{content:"\0025cf "}.lst-kix_l.......
</style>
</head>
<body class="c16">
<!-- a bunch of elements with custom classes -->
</body>
</html>
如何使用包含的样式表安全地将这个文档加载到我的 React 组件中?
class TermsAndConditionsPage extends React.Component {
render() {
// my custom React code here
// the HTML doc here...
}
}
我可以将<body> 标记的内容粘贴到里面,但是我失去了样式。是否可以仅在用户登陆该页面时才加载样式表?
【问题讨论】: