VUE2.0 的 mint-ui 的文本输入框filed 怎么绑定focus blur事件

<v-field  label="用户名:" placeholder="输入用户名" v-model="userName"  @focus="show"></v-field>

用的Mint-ui

show不会执行


Smart猫小萌
浏览 3184回答 1
1回答

回首忆惘然

最后自己找到解决方法了:mt-field 组件中有input元素, 找到input 并且赋予 focus和blur事件;//定义自定义指令来使用//使用&nbsp; v-lfocus 指令<mt-field type="text" placeholder="输入账号" v-model="phone" v-lfcous></mt-field>//自定义指令&nbsp;Vue.directive('lfcous', function(el, pra, a) {&nbsp; &nbsp; let oInput = el.querySelector('input');&nbsp; &nbsp; oInput.onfocus = function() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//创建focus的事件&nbsp; &nbsp; };&nbsp; &nbsp; oInput.onblur = function() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //同时创建blur事件&nbsp; &nbsp; };})
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript