场景:想动态决定el-input的属性show-word-limit是否使用

HTML

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.8.2/lib/index.js"></script>
<div id="app">
<el-input
  type="text"
  placeholder="请输入内容"
  v-model="textContent"
  :maxlength="textInputMaxLength"
  :show-word-limit="showWordLimit"
>
</el-input>
<div style="margin: 20px 0;"></div>
<el-input
  type="textarea"
  placeholder="请输入内容"
  v-model="textareaContent"
  :maxlength="textareaInputMaxLength"
  :show-word-limit="showWordLimit"
>
</el-input>
</div>

 

CSS

@import url("//unpkg.com/element-ui@2.8.2/lib/theme-chalk/index.css");

 

JS

var Main = {
  data() {
    return {
      textContent: '',
      textareaContent: '',      
      textInputMaxLength: 50
      textareaInputMaxLength:100,
      showWordLimit: true
    }
  }
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')

  

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄