使用vue2+axios+chart.js画折线图 ,出现 RangeError: Maximum call stack size exceeded 错误

目录

 

效果图

解决方案

修正要点


效果图

修改前App.vue代码:

<template><div id="app"><canvas id="myChart"></canvas></div>
</template><script>
import axios from 'axios';
import { Chart, registerables } from 'chart.js';
import 'chartjs-adapter-luxon';Chart.register(...registerables);export default {name: 'App',data() {return {chart: null,remainingData: [],speedData: []};},mounted() {this.fetchData();setInterval(this.fetchData, 60000);  // 每分钟更新数据},methods: {fetchData() {axios.get('/data.json').then(response => {console.log('接收数据:', response.data);// 确保转换后的时间戳格式正确,使用 new Date(item.timestamp) 而不是 Date(item.timestamp)this.remainingData = response.data.map(item => {return { x: new Date(item.timestamp), y: item.remaining };});this.calculateSpeed();// 确保remainingData和speedData不为空,防止图例点击时出现undefined错误if (this.remainingData.length === 0) {this.remainingData = [{ x: new Date(), y: 0 }];}if (this.speedData.length === 0) {this.speedData = [{ x: new Date(), y: 0 }];}// 防止无限递归调用,只在数据确实有更新时更新图表if (!this.chart) {this.updateChart();} else {// 更新数据并重新渲染this.chart.data.datasets[0].data = this.remainingData;this.chart.data.datasets[1].data = this.speedData;this.chart.update();  // 只更新已有的图表}}).catch(error => {console.log('获取数据异常:', error);});},calculateSpeed() {const speeds = [];for (let i = 1; i < this.remainingData.length; i++) {const speed = this.remainingData[i].y - this.remainingData[i - 1].y;speeds.push({ x: this.remainingData[i].x, y: speed });}this.speedData = speeds;},updateChart() {this.chart = new Chart(document.getElementById('myChart').getContext('2d'),{type: 'line',data: {datasets: [{label: 'Remaining',data: this.remainingData,borderColor: 'rgb(75, 192, 192)',tension: 0.1,fill: false},{label: 'Speed',data: this.speedData,borderColor: 'rgb(255, 99, 132)',tension: 0.1,fill: false}]},options: {scales: {x: {type: 'time',  // 使用时间轴time: {unit: 'minute',  // 设为 minute 使点不聚集tooltipFormat: 'yyyy-MM-dd HH:mm',displayFormats: {minute: 'HH:mm'  // X 轴时间格式化}},ticks: {source: 'auto',autoSkip: true,maxRotation: 0,  // 防止时间戳旋转}},y: {beginAtZero: true  // 保证 Y 轴从 0 开始}},plugins: {tooltip: {mode: 'index',intersect: false},legend: {onClick: (e, legendItem, legend) => {const datasetIndex = legendItem.datasetIndex;const dataset = legend.chart.data.datasets[datasetIndex];// 确保点击图例时,数据集存在并且被初始化if (!dataset || !dataset.data || !Array.isArray(dataset.data)) {console.log('数据集不存在或者未初始化');return;}// 切换数据集的显示状态dataset.hidden = !dataset.hidden;legend.chart.update();}}},responsive: true,maintainAspectRatio: false}});}}
}
</script>

出现 RangeError: Maximum call stack size exceeded 错误,可能是由于 setInterval 直接引用了 fetchData,而 fetchData 中又更新了图表或页面元素,导致无限递归问题。每次调用 fetchData 可能会触发多次图表更新,最终导致栈溢出。

为了解决这个问题,你可以通过以下方式优化:

解决方案

  1. 使用箭头函数传递上下文:避免 setInterval 中的上下文丢失,确保 this 的正确性。
  2. 防止重复图表创建:在 fetchDataupdateChart 中,确保图表只在需要的时候更新,避免重复调用造成栈溢出。
  3. 处理异步调用:确保每次 fetchData 的数据处理逻辑正确,避免多个请求导致的图表过度更新。

修改后的App..vue 代码:

<template><div id="app"><canvas id="myChart"></canvas></div>
</template><script>
import axios from 'axios';
import { Chart, registerables } from 'chart.js';
import 'chartjs-adapter-luxon';Chart.register(...registerables);export default {name: 'App',data() {return {chart: null,remainingData: [],speedData: [],lastFetchedData: null,  // 存储上次的数据intervalId: null  // 存储 setInterval 的 ID};},mounted() {this.fetchData();this.intervalId = setInterval(this.fetchData, 60000);  // 每分钟更新数据},beforeUnmount() {// 清理定时器,防止组件销毁时继续触发if (this.intervalId) {clearInterval(this.intervalId);}},methods: {fetchData() {axios.get('/data.json').then(response => {console.log('接收数据:', response.data);const newData = response.data.map(item => {return { x: new Date(item.timestamp), y: item.remaining };});// 判断数据是否真的有变化,只有在变化时才更新图表if (JSON.stringify(newData) !== JSON.stringify(this.remainingData)) {console.log('数据发生变化,更新图表');this.remainingData = newData;this.calculateSpeed();// 确保remainingData和speedData不为空if (this.remainingData.length === 0) {this.remainingData = [{ x: new Date(), y: 0 }];}if (this.speedData.length === 0) {this.speedData = [{ x: new Date(), y: 0 }];}// 防止无限递归调用,只在数据确实有更新时更新图表if (!this.chart) {this.updateChart();} else {this.chart.data.datasets[0].data = this.remainingData;this.chart.data.datasets[1].data = this.speedData;this.chart.update();  // 只更新已有的图表}} else {console.log('数据未变化,不更新图表');}}).catch(error => {console.log('获取数据异常:', error);});},calculateSpeed() {const speeds = [];for (let i = 1; i < this.remainingData.length; i++) {const speed = this.remainingData[i].y - this.remainingData[i - 1].y;speeds.push({ x: this.remainingData[i].x, y: speed });}this.speedData = speeds;},updateChart() {this.chart = new Chart(document.getElementById('myChart').getContext('2d'),{type: 'line',data: {datasets: [{label: 'Remaining',data: this.remainingData,borderColor: 'rgb(75, 192, 192)',tension: 0.1,fill: false},{label: 'Speed',data: this.speedData,borderColor: 'rgb(255, 99, 132)',tension: 0.1,fill: false}]},options: {scales: {x: {type: 'time',time: {unit: 'minute',tooltipFormat: 'yyyy-MM-dd HH:mm',displayFormats: {minute: 'HH:mm'}},ticks: {source: 'auto',autoSkip: true,maxRotation: 0,}},y: {beginAtZero: true}},plugins: {tooltip: {mode: 'index',intersect: false},legend: {onClick: (e, legendItem, legend) => {const datasetIndex = legendItem.datasetIndex;const dataset = legend.chart.data.datasets[datasetIndex];if (!dataset || !dataset.data || !Array.isArray(dataset.data)) {console.log('数据集不存在或者未初始化');return;}dataset.hidden = !dataset.hidden;legend.chart.update();}}},responsive: true,maintainAspectRatio: false}});}}
}
</script>

data.json:

[{"remaining": 32.76,"timestamp": "2024-09-10 11:51:19"},{"remaining": 32.78,"timestamp": "2024-09-10 11:50:14"},{"remaining": 32.81,"timestamp": "2024-09-10 11:49:11"},{"remaining": 32.85,"timestamp": "2024-09-10 11:48:06"},{"remaining": 32.88,"timestamp": "2024-09-10 11:47:02"},{"remaining": 32.9,"timestamp": "2024-09-10 11:45:57"},{"remaining": 32.93,"timestamp": "2024-09-10 11:44:53"},{"remaining": 32.95,"timestamp": "2024-09-10 11:43:49"},{"remaining": 32.98,"timestamp": "2024-09-10 11:42:46"},{"remaining": 33.0,"timestamp": "2024-09-10 11:41:41"},{"remaining": 33.03,"timestamp": "2024-09-10 11:40:36"},{"remaining": 33.05,"timestamp": "2024-09-10 11:39:32"},{"remaining": 33.08,"timestamp": "2024-09-10 11:38:27"},{"remaining": 33.1,"timestamp": "2024-09-10 11:37:22"},{"remaining": 33.13,"timestamp": "2024-09-10 11:36:17"},{"remaining": 33.15,"timestamp": "2024-09-10 11:35:12"},{"remaining": 33.2,"timestamp": "2024-09-10 11:34:07"},{"remaining": 33.22,"timestamp": "2024-09-10 11:33:02"},{"remaining": 33.24,"timestamp": "2024-09-10 11:31:57"},{"remaining": 33.26,"timestamp": "2024-09-10 11:30:52"},{"remaining": 33.29,"timestamp": "2024-09-10 11:29:47"},{"remaining": 33.31,"timestamp": "2024-09-10 11:28:42"},{"remaining": 33.33,"timestamp": "2024-09-10 11:27:37"},{"remaining": 33.36,"timestamp": "2024-09-10 11:26:32"},{"remaining": 33.38,"timestamp": "2024-09-10 11:25:28"},{"remaining": 33.4,"timestamp": "2024-09-10 11:24:23"},{"remaining": 33.43,"timestamp": "2024-09-10 11:23:18"},{"remaining": 33.45,"timestamp": "2024-09-10 11:22:15"},{"remaining": 33.47,"timestamp": "2024-09-10 11:21:12"},{"remaining": 33.52,"timestamp": "2024-09-10 11:20:07"},{"remaining": 33.54,"timestamp": "2024-09-10 11:19:04"},{"remaining": 33.56,"timestamp": "2024-09-10 11:18:02"},{"remaining": 33.57,"timestamp": "2024-09-10 11:16:57"},{"remaining": 33.57,"timestamp": "2024-09-10 11:15:52"},{"remaining": 33.58,"timestamp": "2024-09-10 11:14:47"},{"remaining": 33.59,"timestamp": "2024-09-10 11:13:42"},{"remaining": 33.6,"timestamp": "2024-09-10 11:12:39"},{"remaining": 33.61,"timestamp": "2024-09-10 11:11:34"},{"remaining": 33.62,"timestamp": "2024-09-10 11:10:31"},{"remaining": 33.62,"timestamp": "2024-09-10 11:09:26"},{"remaining": 33.63,"timestamp": "2024-09-10 11:08:21"},{"remaining": 33.64,"timestamp": "2024-09-10 11:07:16"},{"remaining": 33.65,"timestamp": "2024-09-10 11:06:12"},{"remaining": 33.66,"timestamp": "2024-09-10 11:05:07"},{"remaining": 33.67,"timestamp": "2024-09-10 11:04:04"},{"remaining": 33.68,"timestamp": "2024-09-10 11:03:00"},{"remaining": 33.69,"timestamp": "2024-09-10 11:01:55"},{"remaining": 33.7,"timestamp": "2024-09-10 11:00:50"},{"remaining": 33.71,"timestamp": "2024-09-10 10:59:46"},{"remaining": 33.72,"timestamp": "2024-09-10 10:58:41"},{"remaining": 33.72,"timestamp": "2024-09-10 10:57:36"},{"remaining": 33.73,"timestamp": "2024-09-10 10:56:33"},{"remaining": 33.74,"timestamp": "2024-09-10 10:55:30"},{"remaining": 33.75,"timestamp": "2024-09-10 10:54:28"},{"remaining": 33.75,"timestamp": "2024-09-10 10:53:25"},{"remaining": 33.76,"timestamp": "2024-09-10 10:52:20"},{"remaining": 33.76,"timestamp": "2024-09-10 10:51:15"},{"remaining": 33.77,"timestamp": "2024-09-10 10:50:11"},{"remaining": 33.78,"timestamp": "2024-09-10 10:49:06"},{"remaining": 33.78,"timestamp": "2024-09-10 10:48:01"},{"remaining": 33.79,"timestamp": "2024-09-10 10:46:56"},{"remaining": 33.79,"timestamp": "2024-09-10 10:45:51"},{"remaining": 33.8,"timestamp": "2024-09-10 10:44:45"},{"remaining": 33.81,"timestamp": "2024-09-10 10:43:40"},{"remaining": 33.81,"timestamp": "2024-09-10 10:42:35"},{"remaining": 33.82,"timestamp": "2024-09-10 10:41:32"},{"remaining": 33.82,"timestamp": "2024-09-10 10:40:27"},{"remaining": 33.83,"timestamp": "2024-09-10 10:39:24"},{"remaining": 33.83,"timestamp": "2024-09-10 10:38:56"},{"remaining": 34.83,"timestamp": "2024-09-10 02:12:51"},{"remaining": 34.83,"timestamp": "2024-09-10 02:11:44"},{"remaining": 34.84,"timestamp": "2024-09-10 02:10:38"},{"remaining": 34.84,"timestamp": "2024-09-10 02:09:31"},{"remaining": 34.84,"timestamp": "2024-09-10 02:08:28"},{"remaining": 34.85,"timestamp": "2024-09-10 02:07:21"},{"remaining": 34.85,"timestamp": "2024-09-10 02:06:16"},{"remaining": 34.86,"timestamp": "2024-09-10 02:05:11"},{"remaining": 34.86,"timestamp": "2024-09-10 02:04:06"},{"remaining": 34.87,"timestamp": "2024-09-10 02:03:03"},{"remaining": 34.87,"timestamp": "2024-09-10 02:01:58"},{"remaining": 34.87,"timestamp": "2024-09-10 02:00:52"},{"remaining": 34.88,"timestamp": "2024-09-10 01:59:48"},{"remaining": 34.88,"timestamp": "2024-09-10 01:58:43"},{"remaining": 34.89,"timestamp": "2024-09-10 01:57:40"},{"remaining": 34.89,"timestamp": "2024-09-10 01:56:35"},{"remaining": 34.9,"timestamp": "2024-09-10 01:55:30"},{"remaining": 34.92,"timestamp": "2024-09-10 01:54:27"},{"remaining": 34.94,"timestamp": "2024-09-10 01:53:22"},{"remaining": 34.96,"timestamp": "2024-09-10 01:52:18"},{"remaining": 34.98,"timestamp": "2024-09-10 01:51:15"},{"remaining": 35.01,"timestamp": "2024-09-10 01:50:09"},{"remaining": 35.03,"timestamp": "2024-09-10 01:49:02"},{"remaining": 35.05,"timestamp": "2024-09-10 01:47:59"},{"remaining": 35.05,"timestamp": "2024-09-10 01:46:55"},{"remaining": 35.05,"timestamp": "2024-09-10 01:45:50"},{"remaining": 35.06,"timestamp": "2024-09-10 01:44:46"},{"remaining": 35.08,"timestamp": "2024-09-10 01:43:41"},{"remaining": 35.1,"timestamp": "2024-09-10 01:42:38"},{"remaining": 35.12,"timestamp": "2024-09-10 01:41:34"},{"remaining": 35.14,"timestamp": "2024-09-10 01:40:31"},{"remaining": 35.15,"timestamp": "2024-09-10 01:39:26"},{"remaining": 35.17,"timestamp": "2024-09-10 01:38:21"},{"remaining": 35.19,"timestamp": "2024-09-10 01:37:18"},{"remaining": 35.21,"timestamp": "2024-09-10 01:36:13"},{"remaining": 35.22,"timestamp": "2024-09-10 01:35:10"},{"remaining": 35.22,"timestamp": "2024-09-10 01:34:05"},{"remaining": 35.26,"timestamp": "2024-09-10 01:31:29"},{"remaining": 35.28,"timestamp": "2024-09-10 01:30:24"},{"remaining": 35.3,"timestamp": "2024-09-10 01:29:21"},{"remaining": 35.31,"timestamp": "2024-09-10 01:28:26"},{"remaining": 35.33,"timestamp": "2024-09-10 01:27:24"},{"remaining": 35.35,"timestamp": "2024-09-10 01:26:19"},{"remaining": 35.37,"timestamp": "2024-09-10 01:25:13"},{"remaining": 35.38,"timestamp": "2024-09-10 01:24:09"},{"remaining": 35.39,"timestamp": "2024-09-10 01:23:03"},{"remaining": 35.41,"timestamp": "2024-09-10 01:21:58"},{"remaining": 35.43,"timestamp": "2024-09-10 01:20:53"},{"remaining": 35.47,"timestamp": "2024-09-10 01:19:06"},{"remaining": 35.49,"timestamp": "2024-09-10 01:18:01"}
]

修正要点

  1. 使用箭头函数在 setInterval 中绑定正确的 this 上下文

    • 使用 setInterval(() => { this.fetchData(); }, 60000),确保 fetchData 在每次调用时使用正确的组件上下文,避免函数指针错误。
  2. 防止重复创建图表

    • 检查 this.chart 是否已存在,只有在首次创建时调用 updateChart,在后续更新中只调用 this.chart.update(),防止不断创建新图表导致的栈溢出。
  3. 优化 fetchData 的数据处理逻辑

    • 确保每次数据更新只更新已有图表,不会触发多余的重绘或递归调用。

通过以上优化,可以避免无限递归和重复调用引发的 Maximum call stack size exceeded 错误。

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

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

相关文章

stm32 W25Q数据存储

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、cubemx配置二、keil中文件修改与配置三、几个重要函数的说明四、DMA方式传输&#xff08;待写&#xff09;总结 前言 W25Q128 容量为128位 128/8 16 也就…

Mac 上终端使用 MySql 记录

文章目录 下载安装终端进入 MySql常用操作查看数据库选择一个数据库查看当前选择的数据库Navcat 打开提示报错参考文章 下载安装 先下载社区版的 MySql 安装的过程需要设置 root 的密码&#xff0c;这个是要进入数据库所设定的&#xff0c;所以要记住 终端进入 MySql 首先输…

Linux基础-Makefile的编写、以及编写第一个Linux程序:进度条(模拟在 方便下载的同时,更新图形化界面)

目录 一、Linux项目自动化构建工具-make/Makefile ​编辑 背景&#xff1a; makefile小技巧&#xff1a; 二、Linux第一个小程序&#xff0d;进度条 先导&#xff1a; 1.如何利用/r,fflush(stdout)来实现我们想要的效果&#xff1b; 2.写一个倒计时&#xff1a; 进度条…

智能家居环境监测系统设计(论文+源码)

1. 系统方案 系统由9个部分构成&#xff0c;分别是电源模块、烟雾传感器模块、GSM发送短信模块、报警模块、温度传感器模块、人体红外感应模块、按键设置模块、显示模块、MCU模块。各模块的作用如下&#xff1a;电源模块为系统提供电力&#xff1b;烟雾传感器模块检测烟雾浓度&…

猫狗识别大模型——基于python语言

目录 1.猫狗识别 2.数据集介绍 3.猫狗识别核心原理 4.程序思路 4.1数据文件框架 4.2 训练模型 4.3 模型使用 4.4 识别结果 5.总结 1.猫狗识别 人可以直接分辨出图片里的动物是猫还是狗&#xff0c;但是电脑不可以&#xff0c;要想让电脑也分辨出图片里的动物是猫还是小…

C++面试3

一、常用设计模式 https://blog.csdn.net/m0_71530237/article/details/141140118?spm1001.2014.3001.5501 二、死锁以及解决方式&#xff1f; 死锁&#xff1a;一种常见的并发问题&#xff0c;发生在多个进程或线程因为竞争资源而陷入相互等待的状态&#xff0c;导致这些进…

Flutter之SystemChrome全局设置

一、简介 SystemChrome作为一个全局属性&#xff0c;很像 Android 的 Application&#xff0c;功能很强大。 二、使用详解 2.1 setPreferredOrientations 设置屏幕方向 在我们日常应用中可能会需要设置横竖屏或锁定单方向屏幕等不同要求&#xff0c;通过 setPreferredOrien…

JavaScript高级——作用域和作用链

1、概念理解&#xff1a; —— 就是一块“地盘”&#xff0c;一个代码所在的区域 —— 静态的&#xff08;相对于上下文对象&#xff09;&#xff0c;在编写代码时就确定了 2、分类 ① 全局作用域 ② 函数作用域 ③ 没有块作用域&#xff08;ES6有了&#xff09; 3、作用 …

WPF利用Path自定义画头部导航条(TOP)样式

1;新建两个多值转换器&#xff0c;都有用处&#xff0c;用来动态确定PATH的X,Y州坐标的。 EndPointConverter 该转换器主要用来动态确定X轴&#xff0c;和Y轴。用于画线条的。 internal class EndPointConverter : IMultiValueConverter {public object Convert(object[] val…

GIS 中的 3D 分析

GIS 中的 3D 分析 3D 分析已成为 GIS 的一个发展趋势&#xff0c;因为它能够更好地表现现实世界。 这不仅仅是为了得到漂亮的图片。对于某些类型的问题&#xff0c;3D 分析有时是解决它们的唯一方法。 3D 数据类型的激增也推动了这一需求。例如&#xff0c;LiDAR、BIM、UAV、…

VS Code 配置 Rust-Analyzer 报错

报错信息&#xff1a; Bootstrap Error" rust-analyzer requires glibc > 2.28 in latest build. 参考了好多地方&#xff0c; https://github.com/rust-lang/rust-analyzer/issues/11558 https://blog.csdn.net/aLingYun/article/details/120923694 https://rust-anal…

C++——⼆叉搜索树

文章目录 一、 ⼆叉搜索树的概念二、⼆叉搜索树的性能分析三、⼆叉搜索树的插⼊四、⼆叉搜索树的查找五、⼆叉搜索树的删除六、二叉搜索树的有序遍历七、⼆叉搜索树的实现代码八、二叉搜索树key与key_value的应用key的应用key_value的应用key/value⼆叉搜索树代码实现 一、 ⼆叉…

C++类与对象深度解析(一):从抽象到实践的全面入门指南

文章目录 C 类与对象——详细入门指南前言1. 类的定义1.1 类定义的基本格式示例代码解释 1.2 访问限定符示例代码解释 1.3 类域示例代码解释 1.4 成员命名规范常见的命名约定&#xff1a;示例&#xff1a;拓展&#xff1a; 1.5 class与struct的默认访问权限示例&#xff1a; 2.…

搭建Windows下的Rust开发环境

【图书介绍】《Rust编程与项目实战》-CSDN博客 《Rust编程与项目实战》(朱文伟&#xff0c;李建英)【摘要 书评 试读】- 京东图书 (jd.com) Rust编程与项目实战_夏天又到了的博客-CSDN博客 2.1.1 安装vs_buildtools 在Windows系列操作系统中&#xff0c;Rust开发环境需要依…

归并排序(Merge Sort)

什么是归并排序 归并排序&#xff08;Merge Sort&#xff09;是一种经典的排序算法&#xff0c;它采用分治法&#xff08;Divide and Conquer&#xff09;策略&#xff0c;将一个大数组分为两个小数组&#xff0c;分别进行排序&#xff0c;然后将这两个已排序的小数组合并成一个…

音视频开发常见的开源项目汇总

FFmpeg 地址&#xff1a;https://ffmpeg.org/介绍&#xff1a;FFmpeg 是一个非常强大的开源多媒体框架&#xff0c;它可以用来处理视频和音频文件。它支持多种格式的转换、编码、解码、转码、流处理等。FFmpeg 包括了 libavformat、libavcodec、libavutil、libswscale、libpos…

组播 2024 9 11

PIM&#xff08;Protocol Independent Multicast&#xff09;是一种常用的组播路由协议&#xff0c;其独立于底层的单播路由协议&#xff0c;能够在多种网络环境中有效地实现多播路由功能。PIM主要有两种模式&#xff1a;PIM Sparse Mode (PIM-SM) 和 PIM Dense Mode (PIM-DM)&…

【C++题解】1580. 扫雷(mine)

欢迎关注本专栏《C从零基础到信奥赛入门级&#xff08;CSP-J&#xff09;》 问题&#xff1a;1580. 扫雷&#xff08;mine&#xff09; 类型&#xff1a;二维数组 题目描述&#xff1a; 扫雷游戏是一款十分经典的单机小游戏。在 n 行 m 列的雷区中有一些格子含有地雷&#x…

I/O 多路复用:`select`、`poll`、`epoll` 和 `kqueue` 的区别与示例

I/O 多路复用是指在一个线程内同时监控多个文件描述符&#xff08;File Descriptor, FD&#xff09;&#xff0c;以便高效地处理多个 I/O 事件。在 UNIX/Linux 和 BSD 系统中&#xff0c;select、poll、epoll、kqueue 都是实现 I/O 多路复用的系统调用。它们各有特点&#xff0…

el-input设置type=‘number‘和v-model.number的区别

el-input设置typenumber’与设置.number修饰符的区别 1. 设置type‘number’ 使用el-input时想收集数字类型的数据&#xff0c;我们首先会想到typenumber&#xff0c;设置完type为number时会限制我们输入的内容只能为数字&#xff0c;不能为字符/汉字等非数字类型的数值&…