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()

 

 

 

 

 

 

 

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM