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)
}
js如何利用encodeURIComponent对数组进行编码
js方法传参参数有空格报错解决方法(escape、unescape)
上面是“vuejs如何实现htmlEncode编码和htmlDecode解码”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3005.html
workflows工作流
雪地里一只可爱的小老虎
一头巨大的古代大象背后建着一座城市
一个精心制作的微型赛车场ComfyUI工作流
五颜六色的球花comfyui工作流
荷塘月色ComfyUI工作流
去掉背景(抠图)comfyui工作流
泰坦尼克号桌面壁纸上ComfyUI工作流
树上挂着一只快乐的荔枝ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用canvas画几个好玩的星云物种
纯html+css做一个3d统计效果
js实现table表格动态新增行和列表
黑客入侵效果代码
用ascii字符画图像
纯css制作卡通头像(随鼠标转头)
jquery做一个漂亮挂墙动态时钟
canvas空间文本射线











