Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

antd vue3

作者:ら非你不取丶   发布日期:2025-02-16   浏览:38

<template>
  <a-button type="primary" @click="showModal">Open Modal</a-button>
  <a-modal v-model:visible="visible" title="Basic Modal" @ok="handleOk">
    <p>Some contents...</p>
  </a-modal>
</template>

<script>
import { defineComponent, ref } from 'vue';
import { Button, Modal } from 'ant-design-vue';

export default defineComponent({
  components: {
    AButton: Button,
    AModal: Modal,
  },
  setup() {
    const visible = ref(false);

    const showModal = () => {
      visible.value = true;
    };

    const handleOk = () => {
      visible.value = false;
    };

    return {
      visible,
      showModal,
      handleOk,
    };
  },
});
</script>

<style scoped>
/* Add some custom styles if needed */
</style>

解释说明:

  1. 模板部分 (<template>):

    • 使用了 a-buttona-modal 组件,分别来自 ant-design-vue
    • a-button 按钮绑定了一个点击事件 @click="showModal",用于显示模态框。
    • a-modal 组件通过 v-model:visible 绑定可见性状态,并定义了标题和内容。
  2. 脚本部分 (<script>):

    • 使用了 Vue 3 的组合式 API (setup 函数)。
    • 导入了 ButtonModal 组件,并在 components 中注册。
    • 定义了一个响应式变量 visible 来控制模态框的显示与隐藏。
    • 定义了两个方法 showModalhandleOk,分别用于显示模态框和关闭模态框。
  3. 样式部分 (<style scoped>):

    • 可以根据需要添加自定义样式。

上一篇:vue3 vuedraggable

下一篇:vue语法

大家都在看

vue.config.js configu

node.js vue

vue查看版本

vue等待几秒

vue3 setup computed

vue screenfull

vue json.stringify

vue 遍历list

typescript vue

vue 复选框

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站