【需求】:进入某个界面,输入框自动获取焦点。
【问题】:使用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();
}
});
【问题描述】:现在这个el操作的是input的父级元素,我要如何才能操作当前这个元素的子元素?
iview api有autofocus