关于iview:IView-Input禁止输入空格IView-vmodeltrim修饰符失效IView输入框禁止输入空格

Iview 输入框Input组件地址 https://iview.github.io/components/input

IViewUI和elementUI还不一样,vue自带的trim禁止输出空格修饰符居然在Input 组件中不起作用。

官网也没有自带什么办法 

<!--IView UI外面   trim修饰符还不起作用 坑爹-->
<Input v-model.trim="value" placeholder="请输出..." @input="inputFun" style="width: 300px"></Input>

解决方案

...

methods:{

//封装成自定义指令最好

inputFun(e) {
   //$nextTick必须
   this.$nextTick(() => {
        //正则过滤空格
        this.value = e.replace(/\s+/g,'');
   }) 
}


}


...

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理