N
N
Nikita2019-05-23 11:49:08
typescript
Nikita, 2019-05-23 11:49:08

How to get screen width in Vue?

There is a component written in Vue.js and TS. It has a computed property:

get isFullCalendar() {
    return (window.screen.width > 1141);
  }

An error is thrown while compiling
[Vue warn]: Error in render: "ReferenceError: window is not defined"

So how do you access the width of the browser window?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-05-23
@Xuxicheta

"lib": [
      "dom"
    ],

in tsconfig

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question