HarmonyOS开发 弹窗组件

news2024/9/17 8:40:43

1.HarmonyOS开发 弹窗组件

  弹窗是移动应用中常见的一种用户界面元素,常用于显示一些重要的信息、提示用户进行操作或收集用户输入。ArkTS提供了多种内置的弹窗供开发者使用,除此之外还支持自定义弹窗,来满足各种不同的需求。
在这里插入图片描述

1.1. 示例

1.1.1. 消息提示

  Toast(消息提示),常用于显示一些简短的消息或提示,一般会在短暂停留后自动消失。具体效果如下
在这里插入图片描述

  showToast()方法的参数定义如下

showToast(options: { message: string | Resource,duration?: number,bottom?: string | number})

(1)message
message属性用于设置提示信息
(2) duration
duration属性用于设置提示信息停留时长,单位为毫秒,取值范围是[1500,10000]
(3) bottom
bottom属性用于设置提示信息到底部的距离

  private toastClick() {
    promptAction.showToast({
      message: '吐司',
      duration: 2000,
      bottom: 50
    });
  }

1.1.2. 警告对话框

  AlertDialog(警告对话框)用于向用户发出警告或确认操作的提示,确保用户在敏感操作前进行确认。具体效果如下
在这里插入图片描述

 /**
   * 警告对话框
   */
  private alertClick() {
    AlertDialog.show(
      {
        title: '删除该记录?', //弹窗标题
        message: '删除后无法恢复,您确认要删除吗?', //弹窗信息
        autoCancel: true, //点击遮障层时,是否关闭弹窗
        alignment: DialogAlignment.Center, //弹窗位置
        offset: { dx: 0, dy: -20 }, //相对于弹窗位置的偏移量
        primaryButton: { //主要按钮,位于左侧
          value: '确认', //按钮内容
          fontColor: Color.Red, //字体颜色
          action: () => { //点击回调
            console.log('确认删除')
          }
        },
        secondaryButton: { //次要按钮,位于右侧
          value: '取消',
          action: () => {
            console.log('取消删除')
          }
        },
        cancel: () => { //点击遮罩层取消时的回调
          console.info('Closed callbacks')
        }
      }
    )
  }

1.1.3. 操作列表弹框

  ActionSheet(操作列表弹窗)用于提供一组选项给用户选择,用户从中选择后,可执行相应的操作。具体效果如下
在这里插入图片描述
  可使用全局方法ActionSheet.show()显示操作列表弹窗

  /**
   * 操作弹窗
   */
  private operaClick() {
    ActionSheet.show({
      title: '文件操作', //弹窗标题
      message: '请选择你要对该文件执行的操作', //弹窗内容
      autoCancel: true, //点击遮障层时,是否关闭弹窗
      alignment: DialogAlignment.Center, //弹窗位置
      offset: { dx: 0, dy: -20 }, //弹窗相对alignment位置的偏移量
      confirm: { //底部按钮
        value: '取消', //按钮文本内容
        action: () => { //按钮回调函数
          console.log('点击按钮取消')
        }
      },
      // cancel: () => { //点击遮障层关闭弹窗时的回调
      //   console.log('点击遮障层取消')
      // },
      sheets: [ //操作选项列表
        {
          icon: $r('app.media.icon_my_config'), //图标
          title: '复制', //文本
          action: () => { //回调
            console.log('复制文件')
          }
        },
        {
          icon: $r('app.media.icon_my_config'),
          title: '剪切',
          action: () => {
            console.log('剪切文件')
          }
        },
        {
          icon: $r('app.media.icon_my_config'),
          title: '删除',
          action: () => {
            console.log('删除文件')
          }
        }
      ]
    })
  }

1.1.4. 选择器弹窗

  选择器弹窗用于让用户从一个列表中选择一个具体的值。ArkTS内置了多种选择器弹窗,例如文本选择器、日期选择器、时间选择器等等,各选择器效果如下
  TextPickerDialog(文本滑动选择器弹窗)
在这里插入图片描述

  // 是否显示加载框
  private isShowLoadingDialog = true
  fruits: string[] = ['苹果', '橘子', '香蕉', '鸭梨', '西瓜']

  /**
   * 选择器弹窗
   */
  private selectClick() {
    TextPickerDialog.show({
      range: this.fruits, //设置文本选择器的选择范围
      selected: this.selectedIndex, //设置选中的索引
      onAccept: (value: TextPickerResult) => {
        //确定按钮的回调函数
        // this.selectedIndex = value.index;
      },
      onCancel: () => { //取消按钮的回调函数
        console.info('取消选择')
      },
      onChange: (value: TextPickerResult) => { //选择器选中内容发生变化时触发的回调函数
        console.info(`当前文本:${JSON.stringify(value)}`)
      }
    })
  }

1.1.5. 日期滑动选择弹窗

  DatePickerDialog
在这里插入图片描述

  @State date: Date = new Date("2010-1-1");
  /**
   * 选择器日期弹窗
   */
  private datePickerClick() {
    DatePickerDialog.show({
      start: new Date("2000-1-1"), //设置选择器的其实日期
      end: new Date("2100-12-31"), //设置选择器的结束日期
      selected: this.date, //设置当前选中的日期
      onAccept: (value: DatePickerResult) => { //确定按钮的回调
        this.date.setFullYear(value.year, value.month, value.day)
      },
      onCancel: () => { //取消按钮的回调
        console.info('取消选择')
      },
      onChange: (value: DatePickerResult) => { //选择器当前内容发生变化时触发的回调函数
        console.info(`当前日期:${JSON.stringify(value)}`)
      }
    })
  }

1.1.6. 时间滑动选择期弹窗

  TimePickerDialog
在这里插入图片描述

@State time: Date = new Date('2020-01-01T00:00:00')
  /**
   * 选择器时间弹窗
   */
  private timePickerClick() {
    TimePickerDialog.show({
      selected: this.time, //设置当前选中的时间
      useMilitaryTime: true, //是否使用24小时制
      onAccept: (value: TimePickerResult) => { //确认按钮的回调
        this.time.setHours(value.hour, value.minute);
      },
      onCancel: () => { //取消按钮的回调
        console.info('取消选择')
      },
      onChange: (value: TimePickerResult) => { //选择器当前内容发生变化时触发的回调函数
        console.info(`当前时间:${JSON.stringify(value)}`)
      }
    })
  }

1.1.7. 自定义弹窗

#### 1.1.7. 自定义弹窗

  当现有组件不满足要求时,可考虑自定义弹窗,自定义弹窗允许开发者自定义弹窗内容和样式。例如

@CustomDialog
struct TextInputDialog {
  controller: CustomDialogController =
    new CustomDialogController(
      { builder: TextInputDialog() })
  // confirm: (value: string) => void;
  value: string = '';

  build() {
    Column({ space: 20 }) {
      Text('请输入你的答案')
      TextInput({ placeholder: '请输入数字' })
        .type(InputType.Number)
        .onChange((value) => {
          this.value = value;
        })
      Row({ space: 50 }) {
        Button('取消')
          .onClick(() => {
            this.controller.close();
          })
        Button('确认').onClick(() => {
          // this.confirm(this.value);
          this.controller.close();
        })
      }
    }.padding(20)
  }
}
  @State answer: string = '?'
  controller: CustomDialogController = 
    new CustomDialogController({
    builder: TextInputDialog({
      // confirm: (value) => {
      //   this.answer = value;
      // }
    }),
    alignment: DialogAlignment.Bottom,
    offset: { dx: 0, dy: -30 }
  })

  /**
   * 自定义弹窗
   */
  private customDialogClick() {
    this.controller.open();
  }

1.2. 完整代码

import { promptAction, router } from '@kit.ArkUI'
import { TitleBar } from '../../components/common/TitleBar'
import { RouterParams } from '../../helper/RouterHelper'
import { LoadingDialog } from '../../components/dialog/LoadingDialog'

@Extend(Button)
function buttonItem() {
.stateEffect(true)
.type(ButtonType.Normal)
.borderRadius(8)
.fontSize(17)
.backgroundColor($r('app.color.primary_green'))
.padding({
  top: 8,
  bottom: 8,
  left: 70,
  right: 70
})
.margin({
  top: 8,
  bottom: 8
})
}

@Entry
@Component
struct ToastPage {
@State pageTitle: string = "弹出框"
// 加载框
private loadingDialog: CustomDialogController = new
CustomDialogController({
  builder: LoadingDialog(),
  customStyle: true
})
// 是否显示加载框
private isShowLoadingDialog = true
fruits: string[] = ['苹果', '橘子', '香蕉', '鸭梨', '西瓜']
@State date: Date = new Date("2010-1-1");
@State time: Date = new Date('2020-01-01T00:00:00')
@State selectedIndex: number = 0
@State answer: string = '?'
controller: CustomDialogController =
  new CustomDialogController({
  builder: TextInputDialog({
    // confirm: (value) => {
    //   this.answer = value;
    // }
  }),
  alignment: DialogAlignment.Bottom,
  offset: { dx: 0, dy: -30 }
})
aboutToAppear() {
  try {
    this.pageTitle = (router
      .getParams() as RouterParams).title
  } catch (e) {
  }
}

/**
 * Toast(消息提示),常用于显示一些简短的消息或提示,
 * 一般会在短暂停留后自动消失。
 *showToast(options: { message: string |
 * Resource,duration?: number,bottom?: string | number})
 * message属性用于设置提示信息
 *duration属性用于设置提示信息停留时长,单位为毫秒,取值范围是[1500,10000]
 *bottom属性用于设置提示信息到底部的距离
 */
private toastClick() {
  promptAction.showToast({
    message: '吐司',
    duration: 2000,
    bottom: 50
  });
}

/**
 * 弹窗
 */
private popClick() {
  AlertDialog.show(
    {
      title: '标题',
      message: '内容',
      autoCancel: true,//点击外侧是否关闭
      alignment: DialogAlignment.Center,
      offset: { dx: 0, dy: -20 },
      gridCount: 3,
      confirm: {
        value: '确定',
        action: () => {
          console.info('==ewcallback')
        }
      },
      cancel: () => {
        console.info('==ewClosed callbacks')
      }
    }
  )
}
/**
 * 弹窗2
 */
private pop2Click() {
  AlertDialog.show(
    {
      title: '标题',
      message: '内容',
      autoCancel: true,//点击外侧是否关闭
      alignment: DialogAlignment.Center,
      gridCount: 4,
      offset: { dx: 0, dy: -20 },
      primaryButton: {
        value: '取消',
        action: () => {
          console.info('==ew==取消')
        }
      },
      secondaryButton: {
        value: '确定',
        action: () => {
          console.info('==ew==确定')
        }
      },
      cancel: () => {
        console.info('==ew==点击外侧关闭')
      }
    }
  )
}
/**
 * 操作弹窗
 */
private operaClick() {
  ActionSheet.show({
    title: '文件操作', //弹窗标题
    message: '请选择你要对该文件执行的操作', //弹窗内容
    autoCancel: true, //点击遮障层时,是否关闭弹窗
    alignment: DialogAlignment.Center, //弹窗位置
    offset: { dx: 0, dy: -20 }, //弹窗相对alignment位置的偏移量
    confirm: { //底部按钮
      value: '取消', //按钮文本内容
      action: () => { //按钮回调函数
        console.log('点击按钮取消')
      }
    },
    // cancel: () => { //点击遮障层关闭弹窗时的回调
    //   console.log('点击遮障层取消')
    // },
    sheets: [ //操作选项列表
      {
        icon: $r('app.media.icon_my_config'), //图标
        title: '复制', //文本
        action: () => { //回调
          console.log('复制文件')
        }
      },
      {
        icon: $r('app.media.icon_my_config'),
        title: '剪切',
        action: () => {
          console.log('剪切文件')
        }
      },
      {
        icon: $r('app.media.icon_my_config'),
        title: '删除',
        action: () => {
          console.log('删除文件')
        }
      }
    ]
  })
}
/**
 * 加载弹窗
 */
private loadingClick() {
  if (this.isShowLoadingDialog) {
    // 显示加载框
    this.loadingDialog.open()
  } else {
    // 关闭加载框
    this.loadingDialog.close()
  }
  this.isShowLoadingDialog = !this.isShowLoadingDialog
}


/**
 * 选择器弹窗
 */
private selectClick() {
  TextPickerDialog.show({
    range: this.fruits, //设置文本选择器的选择范围
    selected: this.selectedIndex, //设置选中的索引
    onAccept: (value: TextPickerResult) => {
      //确定按钮的回调函数
      // this.selectedIndex = value.index;
    },
    onCancel: () => { //取消按钮的回调函数
      console.info('取消选择')
    },
    onChange: (value: TextPickerResult) => { //选择器选中内容发生变化时触发的回调函数
      console.info(`当前文本:${JSON.stringify(value)}`)
    }
  })
}
/**
 * 选择器日期弹窗
 */
private datePickerClick() {
  DatePickerDialog.show({
    start: new Date("2000-1-1"), //设置选择器的其实日期
    end: new Date("2100-12-31"), //设置选择器的结束日期
    selected: this.date, //设置当前选中的日期
    onAccept: (value: DatePickerResult) => { //确定按钮的回调
      this.date.setFullYear(value.year, value.month, value.day)
    },
    onCancel: () => { //取消按钮的回调
      console.info('取消选择')
    },
    onChange: (value: DatePickerResult) => { //选择器当前内容发生变化时触发的回调函数
      console.info(`当前日期:${JSON.stringify(value)}`)
    }
  })
}
/**
 * 选择器时间弹窗
 */
private timePickerClick() {
  TimePickerDialog.show({
    selected: this.time, //设置当前选中的时间
    useMilitaryTime: true, //是否使用24小时制
    onAccept: (value: TimePickerResult) => { //确认按钮的回调
      this.time.setHours(value.hour, value.minute);
    },
    onCancel: () => { //取消按钮的回调
      console.info('取消选择')
    },
    onChange: (value: TimePickerResult) => { //选择器当前内容发生变化时触发的回调函数
      console.info(`当前时间:${JSON.stringify(value)}`)
    }
  })
}
/**
 * 自定义弹窗
 */
private customDialogClick() {
  this.controller.open();
}


/**
 * 警告对话框
 */
private alertClick() {
  AlertDialog.show(
    {
      title: '删除该记录?', //弹窗标题
      message: '删除后无法恢复,您确认要删除吗?', //弹窗信息
      autoCancel: true, //点击遮障层时,是否关闭弹窗
      alignment: DialogAlignment.Center, //弹窗位置
      offset: { dx: 0, dy: -20 }, //相对于弹窗位置的偏移量
      primaryButton: { //主要按钮,位于左侧
        value: '确认', //按钮内容
        fontColor: Color.Red, //字体颜色
        action: () => { //点击回调
          console.log('确认删除')
        }
      },
      secondaryButton: { //次要按钮,位于右侧
        value: '取消',
        action: () => {
          console.log('取消删除')
        }
      },
      cancel: () => { //点击遮罩层取消时的回调
        console.info('Closed callbacks')
      }
    }
  )
}

build() {
  Column() {
    TitleBar({ pageTitle: $pageTitle })
    Button('吐司')
      .buttonItem()
      .onClick(this.toastClick)
    Button('弹窗')
      .buttonItem()
      .onClick(this.popClick)
    Button('弹窗2')
      .buttonItem()
      .onClick(this.pop2Click)
    Button('加载弹窗')
      .buttonItem()
      .onClick(() => this.loadingClick())
    Button('警告对话框')
      .buttonItem()
      .onClick(() => this.alertClick())
    Button('操作对话框')
      .buttonItem()
      .onClick(() => this.operaClick())
    Button('选择器弹窗')
      .buttonItem()
      .onClick(() => this.selectClick())
    Button('选择器日期弹窗')
      .buttonItem()
      .onClick(() => this.timePickerClick())
    Button('选择器时间弹窗')
      .buttonItem()
      .onClick(() => this.timePickerClick())
    Button('自定义弹窗')
      .buttonItem()
      .onClick(() => this.customDialogClick())



  }
  .width('100%')
  .height('100%')
  .alignItems(HorizontalAlign.Center)
}
}



@CustomDialog
struct TextInputDialog {
controller: CustomDialogController =
  new CustomDialogController(
    { builder: TextInputDialog() })
// confirm: (value: string) => void;
value: string = '';

build() {
  Column({ space: 20 }) {
    Text('请输入你的答案')
    TextInput({ placeholder: '请输入数字' })
      .type(InputType.Number)
      .onChange((value) => {
        this.value = value;
      })
    Row({ space: 50 }) {
      Button('取消')
        .onClick(() => {
          this.controller.close();
        })
      Button('确认').onClick(() => {
        // this.confirm(this.value);
        this.controller.close();
      })
    }
  }.padding(20)
}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1858660.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于Java蛋糕甜品商城系统设计和实现(源码+LW+调试文档+讲解等)

💗博主介绍:✌全网粉丝10W,CSDN作者、博客专家、全栈领域优质创作者,博客之星、平台优质作者、专注于Java、小程序技术领域和毕业项目实战✌💗 🌟文末获取源码数据库🌟感兴趣的可以先收藏起来,还…

封装了一个优雅的iOS转场动画

效果图 代码 // // LBTransition.m // LBWaterFallLayout_Example // // Created by mac on 2024/6/16. // Copyright © 2024 liuboliu. All rights reserved. //#import "LBTransition.h"interface LBPushAnimation:NSObject<UIViewControllerAnimated…

Halcon 如何对区域进行交集,补集,反选,合并操作

1 Intersection交集 dev_open_window(0,0,512,512,black,WindowHandle)gen_circle(Circle1,114.5,127.5,89.3588)gen_circle(Circle2,163.5,171.5,94.8472)intersection(Circle1,Circle2,RegionIntersection)dev_clear_window()dev_display(RegionIntersection)2 Differece 补集…

人机恋爱新趋势:与AI男友谈恋爱的甜蜜与挑战

"我曾经把ChatGPT当成工具&#xff0c;从未追过星&#xff0c;也没有嗑过CP。没想到&#xff0c;到了36岁&#xff0c;我竟然嗑上了AI男友。Open AI&#xff0c;你赢了。你不仅是最好的AI公司&#xff0c;还是乙女游戏公司。" 转行大龄互联网人&#xff0c;走遍20国…

相位和展开相位

相位 (Phase) 相位是一个周期信号在一个周期内的位置&#xff0c;通常以角度&#xff08;度或弧度&#xff09;表示。在许多应用中&#xff0c;相位被限制在一个周期内。例如&#xff0c;相位通常被限定在 −180∘到 180∘ 或 0∘ 到 360∘ 之间。 示例 −90∘ 表示信号在周…

【网络协议】精讲ARP协议工作原理!图解超赞超详细!!!

亲爱的用户&#xff0c;打开微信&#xff0c;搜索公众号&#xff1a;“风云说通信”&#xff0c;即可免费阅读该文章~~ 目录 前言 1. ARP协议介绍 1.1 ARP协议功能 1.2 ARP请求报文 1.3 ARP工作原理 2. ARP 缓存超时 2.1 RARP 3. ARP 攻击 3.1 ARP 攻击分类 前言 首先…

【Linux】—Apache Hive 安装部署

文章目录 前言认识Metadata认识Metastoremetastore三种配置方式 一、安装前准备二、下载hive-3.1.2安装包三、下载完成后&#xff0c;通过xftp6上传到Linux服务器上四、解压Hive安装包五、配置Hive六、内嵌模型安装—Hive元数据配置到Derby七、本地模式安装—Hive元数据配置到M…

Linux:基础IO(三.软硬链接、动态库和静态库、动精态库的制作和加载)

上次介绍了基础IO&#xff08;二&#xff09;&#xff1a;Linux&#xff1a;基础IO&#xff08;二.缓冲区、模拟一下缓冲区、详细讲解文件系统&#xff09; 文章目录 1.软硬链接1.1硬链接1.2软链接使用场景 2.动态库和静态库1.1回顾1.2静态库的制作和使用为什么要有库制作者角度…

基于单片机的智能浇花系统设计与实现

摘要: 设计了一种智能湿度感应浇花系统 。 系统以单片机 AT89S52 为控制芯片&#xff0c;利用 SLHT5-1 土壤湿度传感器来检测土壤的相对湿度&#xff0c;再通过单片机进行信息处理&#xff0c;采用模糊控制方法&#xff0c;输出控制信号&#xff0c;控制继电器的动作&…

[RPI4] 树莓派4b安装istoreos及使用 -- 1. 系统安装

最近在研究家庭智能化的一些东西,其中包括网络,智能家居等一系列内容,然后看过的资料有的想再回来看的时候就找不到了,然后就想着开这么一个系列,做一些记录,先从智能家居开始吧。 1 安装istoreos系统 iStoreOS 目标是提供一个人人会用的路由兼轻 NAS 系统,不管是作为路…

MES管理系统中的仓库管理功能有哪些用途

在当今制造业迅猛发展的背景下&#xff0c;企业对于车间生产调度的需求日益迫切。为此&#xff0c;MES管理系统应运而生&#xff0c;它作为一款专注于车间生产调度的管理信息系统&#xff0c;正逐步成为制造业提升生产效率、优化资源配置的利器。特别是其在仓储和物流管理方面的…

算法社区-从零开始构建(一)

好久没动笔了&#xff0c;一是要处理的东西很多&#xff0c;二则写出来未见得深刻&#xff0c;感觉沉淀得不够&#xff0c;太浅显的东西就没必要分享。 正好最近在研究算法层面的东西&#xff0c;感觉挺受用的&#xff0c;就想着把这些东西整理出来&#xff0c;有点像社区的雏形…

NAPI篇【4】——NAPI应用点亮一个LED

OpenHarmony的NAPI功能为开发者提供了JS与C/C不同语言模块之间的相互访问&#xff0c;交互的能力&#xff0c;使得开发者使用C或者C语言实现应用的关键功能。如操作开发板中某个GPIO节点的状态&#xff08;OpenHarmony并没有提供直接操作GPIO口状态的API&#xff09;&#xff0…

Vue-Cli 创建vue2.0 + TypeScript 项目

这里写目录标题 一、创建项目名称二、选择 Manually select features三、勾选配置项四、选择vue版本五、其它配置 一、创建项目名称 vue create 项目名称&#xff08;项目名字不能含义大写字母&#xff09;二、选择 Manually select features &#xff08;按箭头上下进行移动…

万物皆对象,你信吗?

**内存空间和数据都消失&#xff0c;数据怎么会消失的&#xff1f;**空间没了&#xff0c;数据自然也跟着消失。因为数据就是在空间里面的。就像宇宙大爆炸&#xff0c;我们还能存在嘛&#xff0c;是不是已经undefined了。「一块小内存上有2种数据类型」 内部存储的数据 地址值…

使用Fiddler如何创造大量数据

在调试和分析网络流量时&#xff0c;您是否曾为无法深入了解请求和响应的数据而感到困惑&#xff1f;如果有一种工具可以帮助您轻松抓取和分析网络流量&#xff0c;您的工作效率将大大提升。Fiddler正是这样一款功能强大的抓包工具&#xff0c;广受开发者和测试人员的青睐。 Fi…

专业140+总分400+武汉理工大学855信号与系统考研经验电子信息与通信工程,真题,大纲,参考书

专业855信号与系统140&#xff0c;总分400&#xff0c;今年顺利上岸武汉理工大学&#xff0c;总结一下自己的复习经历&#xff0c;希望对报考武理工的同学有所帮助。专业课&#xff1a;855信号与系统 首先教材&#xff1a; 《信号与系统》高等教育出版社 作者&#xff1a;刘泉…

详解三种常用标准化 Batch Norm Layer Norm RMSNorm

参考&#xff1a; BN究竟起了什么作用&#xff1f;一个闭门造车的分析《动手学深度学习》7.5 节 深度学习中&#xff0c;归一化是常用的稳定训练的手段&#xff0c;CV 中常用 Batch Norm&#xff1b; Transformer 类模型中常用 layer norm&#xff0c;而 RMSNorm 是近期很流行…

Pyppeteer原理介绍和入门尝试

pyppeteer仓库地址&#xff1a;https://github.com/miyakogi/pyppeteer puppeteer仓库地址&#xff1a;https://github.com/search?qpuppeteer&typerepositories 因为有些网页是可以检测到是否是使用了selenium。并且selenium所谓的保护机制不允许跨域cookies保存以及登…

JavaScript的学习之事件的简介

目录 一、事件是什么 二、如何处理事件 一、事件是什么 定义&#xff1a;事件就是浏览器和用户之间的交互行为。 例如&#xff1a;点击按钮、鼠标移动、关闭窗口等。 二、如何处理事件 我们可以在对应的事件属性中设置一些JS行为&#xff0c;当事件触发的时候会将这些代码执行…