- 使用defineComponent 定义一个组件
- 使用h函数渲染组件
- 使用createApp 创建组件实例
- 使用mount 插入组件
- 使用unmount移除组件
定义组件
export function Dialog(config) {
const id = 'MwDialog'
const Comp = defineComponent({
props: {
config: {
type: Object,
default: () => ({
})
}
},
setup(props) {
const {
showCancel = true, title = '', content = '', confirmCallback = () => {
}, cancelCallBack = () => {
} } = props.config
const state = reactive({
class: 'mw-dialog bounce-enter' })
const onCancel = () => {
console.log('点击了取消')
removeComp(dialogRef, id)
cancelCallBack(