如何禁用VueStrap Datepicker

时间:2018-06-08 12:59:48

标签: vue.js vue-component vue-strap

我正在使用VueStrap datepicker。 (https://yuche.github.io/vue-strap/#datepicker) 有人可以建议如何禁用datepicker吗?

1 个答案:

答案 0 :(得分:1)

无法禁用datepicker check this component code in github

<input class="form-control datepicker-input" :class="{'with-reset-button': clearButton}" type="text" :placeholder="placeholder"
    :style="{width:width}"
    @click="inputClick"
    v-model="value"/>

因此,您可以添加另一个input as disabled并切换显示/隐藏

 var vm = new Vue({
        components: {
            datepicker:VueStrap.datepicker,
        },
        el: "#app",
        data: {
            emailDate:"2018-03-03",
            disable: true
        }
    })
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-strap/1.1.40/vue-strap.js"></script>
<script>
   
</script>


<div id="app">
 Pick Date
  <div v-show="disable">
    <input disabled :value="emailDate" type="text" placeholder="Select Date" class="form-control datepicker-input with-reset-button" style="width: 200px;">
  </div>
  <div v-show="!disable"><datepicker v-model="emailDate"
									id="datepickerActiondate"
									:format="'yyyy-MM-dd'"
									:clear-button="true"
									:placeholder="'Select Date'" 
									style=""
								>
							</datepicker></div>
<div><button @click="disable = !disable">Toggle Datepicker</button></div>
  
</div>