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

antd of vue

作者:__Man︶ㄣ   发布日期:2025-07-18   浏览:65

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

<script>
export default {
  data() {
    return {
      visible: false,
    };
  },
  methods: {
    showModal() {
      this.visible = true;
    },
    handleOk(e) {
      console.log(e);
      this.visible = false;
    },
  },
};
</script>

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

解释说明:

  • <a-button><a-modal> 是 Ant Design of Vue 提供的组件。
  • v-model:visible="visible":用于控制模态框的显示与隐藏,visible 是一个布尔值,当它为 true 时模态框会显示,反之则隐藏。
  • @click="showModal":点击按钮时触发 showModal 方法,将 visible 设置为 true,从而显示模态框。
  • @ok="handleOk":点击模态框的确认按钮时触发 handleOk 方法,这里简单地将 visible 设置为 false,关闭模态框。

如果你需要更多组件或功能的示例,请参考 Ant Design of Vue 官方文档

上一篇:vue3 router push

下一篇:vue form

大家都在看

vue.config.js configu

node.js vue

vue 图表组件

vue3watch监听多个变量

vue查看版本

vue3 reactive对象重新赋值

vue等待几秒

vue3 setup computed

vue screenfull

vue json.stringify

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

Laravel 中文站