Answer the question
In order to leave comments, you need to log in
How to run plugin if width > 768px?
Please help. It is necessary to run the plugin only if the user's screen width is more than 768px.
nuxt.config.js
module.exports = {
plugins: {
{ src: '~plugins/fullpage-vue.js', ssr: false }
},
build: {
vendor: [
'axios',
'fullpage-vue'
]
}
import Vue from 'vue'
import VueFullpage from 'fullpage-vue'
if (window.screen.availWidth >= 768) {
Vue.use(VueFullpage)
}
Answer the question
In order to leave comments, you need to log in
Do you even understand that if your site is viewed from the most ordinary iPad, then it will be enough to turn it into portrait mode and that's it, your site will break?
To do Vue.use()
depending on the width of the screen is a crutch. In any case, you must connect the plugin, and only then manage its initialization and destruction of the instance in some separate function that you tie to the resize
event.
PS Screen width, if anything, window.innerWidth
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question