当前位置: 首页 > news >正文

前端学习——工具的使用

文章目录

  • 1. 引入一个组件需要什么步骤
  • 2. 监听变量的修改
  • 3. async与await实现异步调用
  • 4. position: relative
  • 5. 定时执行方法

1. 引入一个组件需要什么步骤

引入一个组件,一定不要加{}

(对)import editForm from “./component/editForm”;
(错)import { editForm } from “./component/editForm”;

<template><div style="height: 100%" class="pol-index fence-page"><edit-form							// 步骤2ref="newForm":show.sync="showNewForm":loading="newFormLoading":mode.sync="formType":bureauId="bureauId"@submit="newFormSubmit"/></div>
</template>import editForm from "./component/editForm";			// 步骤1

2. 监听变量的修改

data() {return {tipShow: false;}
},watch:{tipShow(newVal, oldVal){console.log("原始数值为", oldVal);console.log("修改数值为", newVal);}
},

3. async与await实现异步调用

// 获取待处理事件总数async getTotalCount() {let taskCount = await this.getTaskList();let maintenanceCount = await this.getMaintenanceList();let insuranceCount = await this.getInsuranceList();this.totalCount = taskCount + maintenanceCount + insuranceCount;},// 获取待审批任务列表async getTaskList() {// 构造参数let obj = {state: 0,};let data = {...this.page,...obj,};// 访问后端,获取待审批任务列表return new Promise((resolve, reject) => {taskList(data).then((res) => {if (res && res.data) {resolve(res.data.total);}}).catch();});},// 获取保养设备列表async getMaintenanceList() {let data = {...this.page,};return new Promise((resolve, reject) => {searchMaintenance(data).then((res) => {if (res && res.data) {resolve(res.data.total);}}).catch();});},// 获取过期设备列表async getInsuranceList() {let data = {...this.page,};return new Promise((resolve, reject) => {searchInsurance(data).then((res) => {if (res && res.data) {resolve(res.data.total);}}).catch();});},

4. position: relative

position: relative;: 这意味着该元素的定位是相对于其正常位置。
当您为这个元素添加top、right、bottom或left属性时,这些值会相对于其正常位置进行调整。

5. 定时执行方法

// 定义timer对象
data(){return {timer: null,}
}// 初始化timer对象,5秒执行一次getTotalCount()
initTotal() {this.getTotalCount();this.timer = window.setInterval(() => {this.getTotalCount();}, 5000);
},// 销毁timer对象
beforeDestroy() {window.clearInterval(this.timer);
},
http://www.lryc.cn/news/349354.html

相关文章:

  • 图的拓扑序列(BFS_如果节点带着入度信息)
  • Linux常用指令集合
  • 前端 JS 经典:为什么需要模块化
  • MySQL:某字段追加随机数
  • 研发管理-选择研发管理系统-研发管理系统哪个好
  • 学校NTP时钟系统(时间同步系统)方案助力建设智慧校园
  • HTML中打开窗口的类型及使用方法
  • 【userfaultfd+条件竞争劫持modprobe_path】TSGCTF 2021 -- lkgit
  • StNet: Local and Global Spatial-Temporal Modeling for Action Recognition 论文阅读
  • SpringBoot解决CORS跨域——WebMvcConfigurationSupport
  • Linux之内存管理-malloc \kmalloc\vmalloc\dma
  • PyTorch中定义自己的数据集
  • 助力数字农林业发展服务香榧智慧种植,基于YOLOv5全系列【n/s/m/l/x】参数模型开发构建香榧种植场景下香榧果实检测识别系统
  • 2024 年 4 月区块链游戏研报:市场低迷中活跃用户数创新高
  • 排序(一)----冒泡排序,插入排序
  • springcloud简单了解及上手
  • Halcon与深度学习框架结合进行图像分析
  • STL----push,insert,empalce
  • 解决OpenHarmony设备开发Device Tools工具的QUICK ACCESS一直为空
  • k8s拉起一个pod底层是如何运行的
  • Java代理模式的实现详解
  • 数据结构与算法===优先队列
  • HTML常用标签-超链接标签
  • 财务管理|基于SprinBoot+vue的财务管理系统(源码+数据库+文档)
  • 快速学习SpringAi
  • 谈谈 Spring 的过滤器和拦截器
  • 请介绍下H264的多参考帧技术及其应用场景,并请说明下为什么要有多参考帧?
  • 第6章 Elasticsearch,分布式搜索引擎【仿牛客网社区论坛项目】
  • odoo 全局调整list_controller中默认方法(form_controller和kanban_controller等亦可以同样操作)
  • 大模型日报2024-05-13