在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Linux  HTML/ 如何給IView中的輸入框增加一個自定義指令?

如何給IView中的輸入框增加一個自定義指令?

【需求】:進入某個界面,輸入框自動獲取焦點。
【問題】:使用iView框架中的輸入框,如何給這個輸入框添加一個自定義指令?
【代碼】:

iView中的輸入框組件:
<template>
    <Input v-model="value14" v-focus placeholder="Enter something..." clearable style="width: 200px"></Input>
</template>

自定義指令:
Vue.directive('focus', {
    inserted: function (el) {
        console.log('el-->',el);
        // el.focus();
    }
});

【問題描述】:現(xiàn)在這個el操作的是input的父級元素,我要如何才能操作當前這個元素的子元素?

clipboard.png

回答
編輯回答
下墜

iview api有autofocus

   directives: {
    focus: {
      inserted: function(el, binding, vnode) {
         vnode.child.$refs.input.autofocus=true
      },
    },
   }
2017年7月6日 04:32
編輯回答
抱緊我

找到iview中input組件,從底層自定義就好,或者自己自己寫一個input組件

2017年7月5日 10:27