,这是我的App.js
import "./App.css";
import Header from "./component/layout/Header/Header.js";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import React from "react";
import Home from "./component/Home/Home.js";
function App() {
我有一个带有div的id=content,我想将它的innerHtml更改为字符串变量markup,但是我想禁用脚本标记。
例如,如果
markup='<b>Bold text here </b><i><script>alert("JS will be treated as normal text")</script></i>';
content div应该是
Bold文本此处警报(“JS将被视为普通文本”)
我不能使用innerHTML,因为它将运行警报框,也不能使用innerTe
我有以下HTML文件(简化代码): <!DOCTYPE html>
<html lang="en" class="no-js">
...
<body>
This is my header!
{% include "header.tpl.html"%}
</body>
</html> 我在JS中有下面的代码片段,用来替换HTML中所有出现的"header“: const v = 'header';
let re = new RegExp(`${v}`,