1

我在看这个答案(复制如下)

我不明白的是为什么 / 逃脱了?


还有来自 mustache.js 的解决方案

https://github.com/janl/mustache.js/blob/master/mustache.js#L82

 var entityMap = {
    "&": "&",
    "<": "&lt;",
    ">": "&gt;",
    '"': '&quot;',
    "'": '&#39;',
    "/": '&#x2F;'
  };

  function escapeHtml(string) {
    return String(string).replace(/[&<>"'\/]/g, function (s) {
      return entityMap[s];
    });
  }
4

1 回答 1

-1

根本不需要转义 HTML 中的 /。

于 2013-03-12T13:02:18.947 回答