web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

vuejs如何实现htmlEncode编码和htmlDecode解码

950 ℃
     

vuejs如何实现htmlEncode编码htmlDecode解码?下面web建站小编给大家详细介绍一下实现代码!

1、htmlUtil.js封装

export default {
  htmlEncode: function(html) {
    var temp = document.createElement("div");
    (temp.textContent != undefined) ? (temp.textContent = html) : (temp.innerText = html);
    var output = temp.innerHTML;
    temp = null;
    return output;
  },
  htmlDecode: function(text) {
    var temp = document.createElement("div");
    temp.innerHTML = text;
    var output = temp.innerText || temp.textContent;
    temp = null;
    return output;
  }
};

2、index.vue引用

import htmlUtil from '@/js/htmlUtil'

//编码
encode() {
  this.message2 = htmlUtil.htmlEncode(this.message1)
},
//解码
decode() {
  this.message2 = htmlUtil.htmlDecode(this.message1)
}

node.js关于encoding的源码介绍

js如何利用encodeURIComponent对数组进行编码

js方法传参参数有空格报错解决方法(escape、unescape)

织梦dede搬家后后台页面乱码怎么办?

帝国CMS如何解决uft8编码

标签: htmlDecode, htmlEncode, 编码, 解码

上面是“vuejs如何实现htmlEncode编码和htmlDecode解码”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_3005.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计601个字,预计阅读时长5分钟
生活小工具,收录了80多款小工具
上一篇: 基于JavaScrip的web动画库——GSAP
下一篇: 免费商用中文字体——优设鲨鱼菲特健康体
x 打工人ai神器