vue中使用textarea回显不换行

<template>
  <div>
    <el-row v-show="!isedit">
      <el-col :span="18">
        <h3 class="resumecaption">个人优势</h3>
        <span v-html="ruleForm.personalStrength" class="resumecontent"></span>
      </el-col>
      <el-col :span="6" class="rightcol">
        <el-button icon="el-icon-edit" type="text" @click="handleEdit">编辑</el-button>
      </el-col>
    </el-row>
    <el-row v-show="isedit" class="editing">
      <el-col><h2>编辑个人优势</h2></el-col>
      <el-col>
        <el-input
          type="textarea"
          placeholder="请输入内容"
          v-model="ruleForm.personalStrength"
          maxlength="140"
          :autosize="{ minRows: 5}"
          show-word-limit
        >
        </el-input>
      </el-col>
      <el-col class="submitbtn">
          <el-button @click="handlerCancel">取消</el-button>
          <el-button type="primary" @click="submitForm()">完成</el-button>
      </el-col>
    </el-row>
    <cancelDialog ref="canceldialog" @closeDialog="isedit = false"></cancelDialog>
  </div>
</template>

<script>
  import cancelDialog from "./cancelDialog.vue"
  export default {
      data() {
        return {
          isedit: false,
          ruleForm: {
            personalStrength:'',
          }
        };
      },
      components:{
        cancelDialog
      },
      mounted() {
        this.queryZxApplyResumeByCcodePerson();
      },
      methods:{
        handleEdit(){
          this.ruleForm.personalStrength = this.ruleForm.personalStrength.replace(/<br\/>/g, "\n");
          this.isedit = true
        },
        submitForm() {
          let params = Object.assign({}, this.ruleForm);
          this.$busapi.zxApplyResume.saveZxApplyResume(this.qyframe.formRequest(params)).then((res) => {
              if (res.code == "0000") {
                  this.isedit = false
                  } else {
                    this.$message({message: '创建失败,原因:' + res.msg, type: 'error'})
                }
              }).catch((res) => {
                  this.$message({message: res.msg, type: 'error'});
              });
        },
        handlerCancel(){
          this.$refs.canceldialog.dialogVisible=true
        },
        queryZxApplyResumeByCcodePerson(){
           //查询简历
          this.$busapi.zxApplyResume.queryZxApplyResumeByCcodePerson().then((res) => {
                        if (res.code == "0000") {
                          let remarkStr 
                          if(res.data.personalStrength!=''){
                             remarkStr = res.data.personalStrength.replace(/\\n/g, '<br/>')
                          }
                           this.ruleForm.personalStrength =  remarkStr
                           } else {
                             this.$message({message: '错误原因:' + res.msg, type: 'error'})
                          }
                        }).catch((res) => {
                            this.$message({message: res.msg, type: 'error'});
                        });
        }
      }
    };
</script>

<style rel="stylesheet/scss" lang="scss" scoped="scoped">
  @import "~@/assets/scss/resume.scss";
</style>

回显的时候把/n转换成<br/>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值