vue+element: 属性


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

HTML

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

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM