❤ Ant Design Vue 2.28的使用

❤ Ant Design Vue 2.28

弹窗

js 复制代码
//按钮
<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>
      <p>Some contents...</p>
      <p>Some contents...</p>
</a-modal>


<script lang="ts">
import { defineComponent, ref } from 'vue'; //引入 
export default defineComponent({
  setup() {
    const visible = ref<boolean>(false); //定义窗口开关
	//定义窗口事件
    const showModal = () => {
      visible.value = true;
    };
	//窗口事件
    const handleOk = (e: MouseEvent) => {
      console.log(e);
      visible.value = false;
    };
    //返回数值
    return {
      visible,
      showModal,
      handleOk,
    };
  },
});
</script>

下拉框

js 复制代码
<a-select
      ref="select"
      v-model:value="value1"
      style="width: 120px"
      @focus="focus"
      @change="handleChange">
      <a-select-option value="jack">Jack</a-select-option>
      <a-select-option value="lucy">Lucy</a-select-option>
      <a-select-option value="disabled" disabled>Disabled</a-select-option>
      <a-select-option value="Yiminghe">yiminghe</a-select-option>
</a-select>

//数据
const options1 = ref<SelectTypes['options']>([
      {
        value: 'jack',
        label: 'Jack',
      },
      {
        value: 'lucy',
        label: 'Lucy',
      },
      {
        value: 'disabled',
        label: 'Disabled',
        disabled: true,
      },
      {
        value: 'yiminghe',
        label: 'Yiminghe',
      },
]);



//方法
const focus = () => {
      console.log('focus');
    };

const handleChange = (value: string) => {
      console.log(`selected ${value}`);
};
相关推荐
伍哥的传说15 分钟前
Mitt 事件发射器完全指南:200字节的轻量级解决方案
vue.js·react.js·vue3·mitt·组件通信·事件管理·事件发射器
程序员码歌2 小时前
【零代码AI编程实战】AI灯塔导航-总结篇
android·前端·后端
用户21411832636023 小时前
免费玩转 AI 编程!Claude Code Router + Qwen3-Code 实战教程
前端
一枚小小程序员哈3 小时前
基于Vue + Node能源采购系统的设计与实现/基于express的能源管理系统#node.js
vue.js·node.js·express
小小愿望4 小时前
前端无法获取响应头(如 Content-Disposition)的原因与解决方案
前端·后端
小小愿望4 小时前
项目启功需要添加SKIP_PREFLIGHT_CHECK=true该怎么办?
前端
烛阴4 小时前
精简之道:TypeScript 参数属性 (Parameter Properties) 详解
前端·javascript·typescript
海上彼尚5 小时前
使用 npm-run-all2 简化你的 npm 脚本工作流
前端·npm·node.js
开发者小天6 小时前
为什么 /deep/ 现在不推荐使用?
前端·javascript·node.js
如白驹过隙6 小时前
cloudflare缓存配置
前端·缓存