vue window.innerWidth

thgus·2023년 7월 27일
0

vue

목록 보기
4/4

vue 로 반응형 작업을 하기 위해서 dom이 그려지기 전의 창 크키가 필요했다.
DOM 이 그려지기 전의 실행을 위해 mounted에서 this.$nexTick()을 사용했다.

 this.$nextTick(() => {
            let windowWidth = window.innerWidth;
            console.log(windowWidth);

            if (windowWidth <= 767) {
                console.log("Window width is 767px or less");
            } else {
                console.log("asdf");
            }
        })
profile
어쩌다보니IT

1개의 댓글

comment-user-thumbnail
2023년 7월 27일

잘 읽었습니다. 좋은 정보 감사드립니다.

답글 달기