htmlEncode htmlDecode

htmlEncode htmlDecode
v-html: 如果是富文本,直接导入;如果不是富文本,需要htmlEncode再导入


htmlEncode : function(value){
  return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
},


htmlDecode : function(value){
  return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
},

原文链接:https://blog.csdn.net/x_duoduoluo/article/details/128931321

 

 

posted on 2023-11-08 11:42  itjeff  阅读(94)  评论(0)    收藏  举报

导航