출처 : https://v2.vuejs.org/v2/guide/custom-directive.html
import Vue from 'vue';
Vue.directive(이름, 함수)
UV
plugins/directives.js
import directive를 정의한 파일
import Vue from 'vue';
export default function () {
Vue.directive('정의하고 싶은 이름', 실행 될 함수);
}
사용할 때 'v-정의한 이름'의 형태로 쓸 수 있다
directives : {
focus : {
inserted: function (el){
el.focus()
}
}
}
cf. window.matchMedia(mediaQueryString)
: 주어진 미디어 쿼리 문자열의 분석 결과를 나타내는 MediaQueryList 객체를 반환
document에 적용된 media query에 대한 정보를 저장한다
immediate and event-driven matching against the state of the document
https://www.geeksforgeeks.org/underscore-_-debounce-function/
_.debounce(function, wait, immediate)
function : debounce 될 함수
wait : milisec 단위로
immediate : sequence의 시작 또는 끝 중에 어디서 실행되고 싶은지 설정할 때 사용 boolean
MediaQueryList
serialization : 컴퓨터 과학의 데이터 스토리지 문맥에서 데이터 구조나 오브젝트 상태를 동일하거나 다른 컴퓨터 환경에 저장하고 나중에 재구성할 수 있는 포맷으로 변환하는 과정
const {matches} = window.matchMedia('(hover:none), (pointer:coarse)')
