Vue pass slot template to extended component

前端 未结 5 1545
Happy的楠姐
Happy的楠姐 2021-01-12 02:24

Is any way to pass a template to extended component? Example, that illustrates the problem:

There is a component named Slide with a template like so:

5条回答
  •  鱼传尺愫
    2021-01-12 02:51

    If you are open to change your approach a little bit, a instead of :

    https://jsfiddle.net/jonataswalker/z5Lgbjv8/

    const Parent = {
      template: `
    parent content
    `, data() { return { view: '' } } } const Other = { template: `

    from Other

    ` } const Slide = Vue.extend(Parent) // how to pass template to the Parent`s slot? new Slide({ data: { view: Other } }).$mount('#container')

提交回复
热议问题