[Vuejs]-Vue reusable dialog

0👍

It sounds like you want to use components. Check the docs and it may help. Basically you can put a component in a component as I think you want and then use the parent component in a page somewhere. It might start getting a bit messy if you want to replace part of a component if a child component is present and I honestly wouldn’t know how to do that, perhaps someone else would.

Layering components like this can make it more difficult if you are trying to pass data between them so you need to be careful of that.

Also, your template code above would likely not work because as the error would tell you "Component template should contain exactly one root element." So you’d need:

<template>
  <div>
    <slot name="modal-header"/>
    <slot name="modal-footer"/>
  </div>
</template>

Leave a comment