<template>
  <div class="demo-modal-form">
    <ui-button @click="handleClick">
      点击打开弹窗(命令式)
    </ui-button>
  </div>
</template>

<script>
import { Button } from "amumu-ui"
import createPortal from "amumu-ui/src/factory/create-portal"
import FormModal from "./form-modal"

export default {
  components: {
    "ui-button": Button,
  },
  data() {
    return {
      visible: false,
    }
  },
  methods: {
    handleClick() {
      const instance = createPortal({
        context: this,
        component: FormModal,
        props: {
          visible: true,
        },
      })

      setTimeout(() => {
        instance.update({
          props: {
            title: "现在就登陆！",
          },
        })
      }, 3000)
    },
  },
}
</script>
