如何使用VueJS关注负载?
如果使用jquery,我应该做的就是:
$(document).ready(function() {
$('#username').focus();
});
有没有办法?
如何使用VueJS关注负载?
如果使用jquery,我应该做的就是:
$(document).ready(function() {
$('#username').focus();
});
有没有办法?
您可以为此创建自定义指令:
// Register a global custom directive called v-focus
Vue.directive('focus', {
// When the bound element is inserted into the DOM...
inserted: function (el) {
// Focus the element
el.focus()
}
})
然后像这样使用:
<input v-focus>