Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hunterliu1003/vue-use-template

Control Vue Component programmatically by using a useTemplate composable
https://github.com/hunterliu1003/vue-use-template

composable nuxt3 usetemplate vue vue3

Last synced: 12 days ago
JSON representation

Control Vue Component programmatically by using a useTemplate composable

Awesome Lists containing this project

README

        

# vue-use-template

## Playground

- [Stackblitz for Vue 3](https://stackblitz.com/github/hunterliu1003/vue-use-template/tree/master/examples/vue3)
- [Stackblitz for Nuxt 3](https://stackblitz.com/github/hunterliu1003/vue-use-template/tree/master/examples/nuxt3)

## App.vue

```vue

import { TemplateProvider, useTemplate } from 'vue-use-template'

// Support Ref, Reactive, Computed
const props = reactive({
title: 'Hello World!'
})

const { show, hide } = useTemplate({
component: defineAsyncComponent(() => import('./DialogConfirm.vue')),
props,
emits: {
onConfirm: () => {
alert('Confirm!')
hide()
},
onCancel: () => hide(),
},
slots: {
default: defineTemplate({
component: () => h('p', 'This is a dialog content.'),
}),
},
})


App





```

## DialogConfirm.vue

```vue

defineProps<{
title: string
}>()

const emit = defineEmits<{
(e: 'confirm'): void
(e: 'cancel'): void
}>()


{{ title }}




Confirm


Cancel

```