vue render v html,javascript - Vue v-html renders [object HTMLQuoteElement] - Stack Overflow

I'm trying to create a generic slideshow component using slots. I'm able to access the elements passed into the slot, and when I log them they appear to be DOM elements, but when they appear on the page they're just [object HTMLQuoteElement].

Here's the component:

export default {

props: {

// Classes to apply to wrapping element.

cssClasses: { default: '' },

// Integer for miliseconds to remain on each slide.

interval: { default: 5000 }

},

data() {

return {

// Internal: Timer for playing through slides.

timer: null,

// Internal: Current slide.

index: 0

}

},

computed: {

currentSlide() {

if (this.$slots.default[this.index].elm) {

console.log('currentSlide', this.$slots.default[this.index].elm) // prints correctly

return this.$slots.default[this.index].elm // renders wrong

}

return ''

},

slots() {

return this.$slots.default

}

},

methods: {

// Internal: Start slideshow.

startSlide() {

if (this.timer) clearInterval(this.timer)

this.timer = setInterval(this.next, this.interval)

},

// Internal: Render next slide. If at end, return to the beginning.

next() {

this.startSlide()

if (this.index === this.slots.length - 1) {

this.index = 0

} else {

this.index += 1

}

}

},

mounted() {

this.startSlide()

}

}

The goal is to be able to pass any html elements into the slot so the slideshow goes through them. At this point I'm just adding nonsense text because stack overflow won't let me post my question because it's mostly code. But really, there isn't much more to say. You can read the code. You know what I'm trying to do. If I'm doing something wrong, let me know. There isn't a point in me wasting both of our time so a robot can count characters to decide one has enough information.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值