Vue文字转编码与解码

最近用到的,文字输入框是一个组件,在后台管理系统中保存,关键代码如下:

<el-form-item v-if="modelForm.type && modelForm.type == 'ABOUTUS'" label=" " prop="desc" > <span style="text-line:center">企业简介</span> <Tinymces ref="editor" :action="$axios.getUrl() + '/management/fileupload/image'" v-model="detailText" :height="700" /> </el-form-item> ...................................... data() { return { types: [], detailText: "", .................... }
} methods: { .................... initData() { var that = this; if (this.id != "") { this.activityId = this.id; this.isSave = false; this.$axios .get( "/management/basedata/menuBanners/" + this.activityId + "/update" ) .then(res => { this.modelForm = res.content.menuBanner; if (this.modelForm.video) { this.fileList = [ { name: this.modelForm.video.substring( this.modelForm.video.lastIndexOf("/") + 1 ), url: this.modelForm.video } ]; } this.detailText = decodeURIComponent(this.modelForm.detail); this.types = res.content.types; }) .catch(res => {}); } else { ............................................

 

网站部分代码:

<div class="weui-col-50 item gren animated bounceInLeft"> <div v-html="form.detail"></div> </div>
getImg() { this.$http .get('/getBannerInfo?type=ABOUTUS') .then(res => { console.log(res) this.form = res.body.content this.form.detail = encodeURI(this.modelForm.detail) ......................... console.log(this.form) }) .catch(res => {}) },

解码一个编码的 URI 组件

decodeURIComponent()

把字符串编码为 URI

encodeURI()

 

 

 

 

 

 

 

 

......................今天也是想他的一天

 


__EOF__

本文作者fiamme
本文链接https://www.cnblogs.com/vivin-echo/p/14060007.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   fiamme  阅读(2775)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示