❤ 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}`);
};
相关推荐
p***h6433 分钟前
React数据分析应用
前端·react.js·前端框架
4***99743 分钟前
TypeScript类型体操
前端·javascript·typescript
u***09644 分钟前
TypeScript装饰器
前端·javascript·typescript
h***839317 分钟前
React虚拟现实开发
前端·react.js·vr
7***n7521 分钟前
React虚拟现实案例
前端·react.js·vr
IT_陈寒36 分钟前
JavaScript 闭包通关指南:从作用域链到内存管理的8个核心知识点
前端·人工智能·后端
默恋~微凉43 分钟前
shell(八)——WEB与Nginx
开发语言·前端·php
要加油哦~1 小时前
nrm | npm 的镜像管理工具
前端·npm·node.js·nrm
想不明白的过度思考者1 小时前
基于 Spring Boot 的 Web 三大核心交互案例精讲
前端·spring boot·后端·交互·javaee
孟祥_成都1 小时前
不易懂你打我!写给前端和小白的 大模型(ChatGPT) 工作基本原理!
前端·人工智能