Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't select element generated by third-party Vue plugin

I'm using Owl Carousel for Vue. It doesn't seem to work properly since all carousel items are visible in their global container, which is several screens wide (there's no overflow: hidden or any max-width to make only x items visible at a time).

Anyway I find myself forced to apply some container class to a wrapper that the plugin generates dynamically. To that end I do:

mounted () {
    this.$nextTick(() => {
      document.querySelector('.owl-carousel').classList.add('container')
    })
}

But, querySelector('.owl-carousel') is null although I see it in the DOM.

How can I successfully select it?

like image 807
drake035 Avatar asked Dec 12 '25 02:12

drake035


1 Answers

wow a jquery plugin wrapped into vue ... with like 200 lines of props ...

props start here: L23

props end here : L220

but honestly just add your class here:

<div :id="elementHandle" :class="['owl-carousel', 'owl-theme', 'your-class-here']">

  • fork it

  • customize it

  • npm install <git repo url>

like image 152
Estradiaz Avatar answered Dec 13 '25 23:12

Estradiaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!