반응형
로드 시 포커스 텍스트 상자의 Vue.js
VueJ를 사용하여 로드에 집중하는 방법
jquery를 사용할 경우 해야 할 일은 다음과 같습니다.
$(document).ready(function() {
$('#username').focus();
});
vueway가 있나요, 없나요?
이에 대한 커스텀 디렉티브를 작성할 수 있습니다.
// 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>
문서의 전체 예: https://vuejs.org/v2/guide/custom-directive.html
Directive documents : https://vuejs.org/v2/api/ #Vue-directive
언급URL : https://stackoverflow.com/questions/41297475/vue-js-on-focus-textbox-on-load
반응형
'sourcecode' 카테고리의 다른 글
main()은 C와 C++에서 무엇을 반환해야 합니까? (0) | 2022.07.23 |
---|---|
Linux __user 매크로의 의미는 무엇입니까? (0) | 2022.07.23 |
VM이 정의되어 있지 않습니다(vueC가 있는 vueJ).리 (0) | 2022.07.23 |
x<1과 x<10 중 어느 쪽이 빠릅니까? (0) | 2022.07.23 |
C++ - unistd를 포함합니다.왜 cunistd 안 돼? (0) | 2022.07.23 |