0
点赞
收藏
分享

微信扫一扫

5V继电器模块详解(STM32)

徐一村 2024-09-26 阅读 18
chrome前端

输入文字长度 + 指定标签的长度 (判断长度并提示)

<div style="position: relative;" class='changyongyu'>
        <el-input type="textarea" :autosize="{ minRows: 8, maxRows: 8 }" style="margin-bottom:10px;"
          v-model.trim="ruleForm.content" maxlength="500" @input="inputchangyongyu" @change="inputchangyongyu"
          @paste.native.capture.prevent="handleFalse" 
          ></el-input>
        <div style="position: absolute;right: 10px;bottom: -10px;">{{
            textlength > 500 ? '500' : textlength }} / 500</div>
      </div>


// 计算长度字段属性添加 开始
  computed: {
    textlength() {
      // #{store_name}
      // #{store_phone}
      // #{store_addr}
      let num_store_name = 0
      let num_store_addr = 0
      let num_store_phone = 0
      let mintextlength = 0
      // 门店名称 : 25个字段   门店地址 :50个字段, 电话:15个字段  
      num_store_name = (this.ruleForm.content.match(/#{store_name}/g) || []).length * 25;
      num_store_addr = (this.ruleForm.content.match(/#{store_addr}/g) || []).length * 50;
      num_store_phone = (this.ruleForm.content.match(/#{store_phone}/g) || []).length * 15;
      mintextlength = this.ruleForm.content.replace(/#{store_name}/g, '').replace(/#{store_addr}/g, '').replace(/#{store_phone}/g, '')
      let num = num_store_phone + num_store_addr + num_store_name
      return num + mintextlength.length
    }
  },

// 计算属性结束



    inputchangyongyu(val) {
      if (this.textlength > 500) {
        this.$message.warning(`总字数超出了长度!请精简字数`);
        this.ruleForm.content = val.slice(0, -1);
        return val;
      }
    },
 //方法
    handleFalse(e) {
      let clip = e.clipboardData.getData('Text');
      let num =  this.textlength + clip.length
      if(num > 500){
        this.$message.warning(`粘贴字数超出了长度!请精简字数`);
        return true;        
      }else{
        this.ruleForm.content += String(clip)
      }
      //终止
    },

在这里插入图片描述

举报

相关推荐

0 条评论