-
-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and 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
Nuxt exemple #831
Comments
Not sure how that would differ from the VueJS example. But if it is different, I'd be happy to add it to the docs. |
It's not significantly different. If you're looking to register the directive globally, the conventional way is to put the directive shown in the VueJS example in a file under the plugins directory: // plugins/iframe-resize.js
import Vue from 'vue'
import iframeResize from 'iframe-resizer/js/iframeResizer'
Vue.directive('resize', {
bind: function(el, { value = {} }) {
el.addEventListener('load', () => iframeResize(value, el))
}
}) then register the plugin in // nuxt.config.js
export default {
plugins: [
{ src: '~/plugins/iframe-resize', mode: 'client' }
]
} If you only want to use it locally, you could register it under the Vue component's import iframeResize from 'iframe-resizer/js/iframeResizer';
export default {
directives: {
resize: {
bind (el, { value = {} }) {
el.addEventListener('load', () => iframeResize(value, el))
}
}
}
} Check the Vue.js docs for more on custom directives. Instead of a directive, you could also make a custom component and use the component's API as a gateway to iframe-resizer's, but that's more of a general Vue.js consideration than anything specific to Nuxt.js. |
I would love this as well, is there any example or solution for a Nuxt application? |
I'm having trouble wit this - I've tried implementing like suggested by @vondras. I don't get any errors besides the log from the "v-resize='{log: true}'. In the browser, nothing happens implementation:
|
Any nuxt 3 examples? |
After a whole morning of trial and error, I used @vondras method but the real problem was that I forgot to place the iframeResizer.contentWindow.min.js file in my iFrame file script. Also I needed to host the contentWindow file (I just uploaded it to the same bucket as the file I use for the iFrame). Reading the documentation patiently would've saved me a couple hours. |
To use this package with Nuxt3, create a new plugin in your project's plugins directory. Define a new Nuxt plugin and use the Vue resize directive to add the iframeResize method.
|
@vfcoding I tried your code I get no errors whatsoever but nothing happens, I don't get logs in the console. |
After some digging I managed to make it work with this code
|
We now have a Vue package that I think should work in Nuxt |
Hello
I would like to use iframe-resizer with nuxt to resize a cross domain iFrame
Do someone have an exemple with nuxt please?
The text was updated successfully, but these errors were encountered: