Commit 8f8e393b authored by Zhang Xiaojie's avatar Zhang Xiaojie

输入框组件优化

parent b20ee4aa
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
</span> </span>
<span class=" absolute right-0 leading-7">{{getSize}}/<slot name="limit"></slot></span> <span class=" absolute right-0 leading-7">{{getSize}}/<slot name="limit"></slot></span>
</div> </div>
<div class="content h-12 text-base flex content-center"> <div class="content h-13 my-3">
<input class=" text-text-primary placeholder-mygray border-0 w-full" v-model="text" type="text" :placeholder="hint"> <input class=" text-text-primary text-base placeholder-mygray border-0 w-full leading-5" v-model="text" type="text" :placeholder="hint" @blur="isNull">
<p class="text-xs mt-1 text-red-600" v-show="show">*不可为空</p>
</div> </div>
</div> </div>
</template> </template>
...@@ -27,9 +28,17 @@ export default Vue.extend({ ...@@ -27,9 +28,17 @@ export default Vue.extend({
data(){ data(){
return{ return{
text:'', text:'',
show:false
} }
}, },
methods:{ methods:{
isNull():void{
if(this.text ===''){
this.show = true
}else{
this.show = false
}
}
}, },
computed:{ computed:{
getSize():number{ getSize():number{
...@@ -38,7 +47,7 @@ export default Vue.extend({ ...@@ -38,7 +47,7 @@ export default Vue.extend({
}, },
watch:{ watch:{
text():void{ text():void{
let size:number = Number(this.$slots.limit![0].text) let size = Number(this.$slots.limit![0].text)
if(this.getSize >= size){ if(this.getSize >= size){
this.text = this.text.substring(0,size) this.text = this.text.substring(0,size)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment