vue+element: 屬性

場景:想動態決定el-input的屬性show-word-limit是否使用javascript

HTMLcss

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

 

CSSvue

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

 

JSjava

var Main = {
  data() {
    return {
      textContent: '',
      textareaContent: '',      
      textInputMaxLength: 50
      textareaInputMaxLength:100,
      showWordLimit: true
    }
  }
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
相關文章
相關標籤/搜索