-
Notifications
You must be signed in to change notification settings - Fork 69
how can i use single component? (nuxt) #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue an 8000 d contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Try to import vue-product-zoomer as a Nuxt plugin. Create the file ~/plugins/vue-product-zoomer.js : import Vue from 'vue'
import ProductZoomer from 'vue-product-zoomer'
Vue.use(ProductZoomer) And then bind it in nuxt.config.js : export default {
// ...
plugins: [
'~/plugins/axios.js',
'~/plugins/vue-product-zoomer.js'
],
// ...
} Finally, use the component wherever you want in a .vue template <product-zoomer
:base-images="images"
:base-zoomer-options="zoomerOptions"
/> |
I tried importing it as a nuxt plugin. // ~/plugins/product-zoomer.js
import Vue from 'vue'
import ProductZoomer from 'vue-product-zoomer'
Vue.use(ProductZoomer) // nuxt.config.js
...
plugins: [
...
{ src: '~/plugins/product-zoomer.js', mode: 'client' },
]
... // Using it as:
<template>
<client-only>
<ProductZoomer :base-images="images" :base-zoomer-options="zoomerOptions" />
</client-only>
</template> The issue is it doesn't work on initial load of the page. |
This module only run the detail page. That's why I loaded this module dynamically on the detail page. // ~/plugins/product-zoomer.js
import Vue from 'vue'
import ProductZoomer from 'vue-product-zoomer'
Vue.use(ProductZoomer)
// Trigger for mounted
data() {
return {
isMounted: false,
}
}
// Dynamic load when mounted
async mounted() {
await Promise.all([import('@/plugins/vue-product-zoomer.js')])
this.isMounted = true
}
<section v-if="isMounted" class="detail-gallery">
<ProductZoomer :base-images="images" :base-zoomer-options="zoomerOptions" />
</section>```
It worked like this but sometimes can't get the width value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
So now what can I do to not be global? I found my answer on this site.
I use a single component on my project but I have an error.
pls, help me with this error.
so I use this for my code.
if we run project
we can see error
Well look at this interesting point if I come to pick up the brackets`
and if I refresh my page can see this error
pleas help meeeeeeeeeeeeee.
what can I do ????????????????????????????
The text was updated successfully, but these errors were encountered: