<li class="ct-li" v-for="list in checkdData" :style="{ fontSize: sliderValue + 'px' }"> <div class="ct-li-wrap"> <span>{{ list.index }} 、</span> <div class="ct-li-info"> <p>排号: <span>{{list.UserId}}</span> &nbsp;&nbsp; <span>{{processName(list.name) }}</span> &nbsp;&nbsp; <span v-if="list.States === '过号' " :key="list.index" :style="list.States === '过号' ? 'color: red;' : ''">(过号)</span> </p> <p>{{ list.Djlsh }}</p> </div> </div> </li><input type="text" placeholder=" 输入流水号回车" class="input-ct" v-model="inputDrValues" @keydown.enter="onEnters"/>mounted() { this.grilData(); this.manData(); setInterval(() => { this.grilData(); // 每5秒获取一次数据 this.manData(); }, 500000); },async onEnter(){ try{ const roomnumber = '03'; const djlsh = this.inputValue; const isExist = this.matchedData.some(data => data.Djlsh === djlsh); if(!isExist){ const url = getCt(); const CTData = await fetchCt(url, roomnumber,djlsh ); //排队完成 this.couter1++; this.matchedData.push(CTData); this.inputValue=''; }else{ console.log("该流水号输入过") } }catch(e){ console.log("排队失败"); } },async grilData(){ try{ const gender = '0'; const roomnumber = '03'; // const urls = getCtUrl(); // const CTDatas= await fetchLine(urls,roomnumber,gender); const response = await axios.get('/line.json'); //女生数据 const CTDatas = response.data; console.log("CTDatas",CTDatas); //让获得的数据按顺序来排 this.matchedData = CTDatas.data.list.filter(data => data.States !== "正在检").map((data, index) => { data.index = index +1 ; // this.couter1++; // 计数器递增 return data; }); this.matchedData.forEach(data => { if (data.States === '叫号') { console.log("叫号",data); this.startSpeech({...data, RoomNumber: roomnumber}); } }); }catch(e){ console.log("获取数据库信息失败"); } },processName(name) { if (name.length === 2) { return name[0] + '*'; } else if (name.length === 3) { return name[0] + '*' + name[2]; } else { return name; } },为什么会显示Uncaught (in promise) TypeError: name is undefined

时间: 2024-04-16 16:27:48 浏览: 22
根据你提供的代码,在`processName`方法中可能会抛出`Uncaught (in promise) TypeError: name is undefined`错误的原因是`name`参数未定义。可能是在某些情况下,传入的`name`参数为`undefined`。 为了解决这个问题,你可以在调用`processName`方法之前添加一个条件判断来检查`name`是否存在。如果`name`不存在,你可以返回一个空字符串或其他默认值。 下面是修改后的代码示例: ```javascript processName(name) { if (!name) { return ''; // 或者返回其他默认值 } if (name.length === 2) { return name[0] + '*'; } else if (name.length === 3) { return name[0] + '*' + name[2]; } else { return name; } } ``` 通过添加条件判断,当`name`不存在时,不再执行后续的操作,避免了抛出错误。这样修改后,你就不会再遇到`Uncaught (in promise) TypeError: name is undefined`错误了。
相关问题

<main-content :ifDetail="true"> <div class="two-side"> <div class="main-left"> <el-form :model="form" :rules="rules" ref="form" label-width="120px"> <el-form-item label="选择下载模块" prop="accountName"> <el-input v-model.trim="form.accountName" :maxlength="50"></el-input> </el-form-item> <el-form-item label="倾斜度"> <el-slider v-model.number="form.rotate" :min="-180" :max="180"></el-slider> </el-form-item> <el-form-item label="文字"> <el-input type="textarea" v-model="form.text"></el-input> </el-form-item> <el-form-item label="文字大小"> <el-input-number v-model.number="form.fontSize" :min="10" :max="50"></el-input-number> px </el-form-item> <el-form-item label="位置"> <el-select placeholder="请选择位置" v-model="form.alignment"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option> </el-select> </el-form-item> <el-form-item> <el-select v-if="form.alignment === 2" placeholder="请选择位置" v-model="form.textPosition"> <el-option v-for="item in textPositionOptions" :key="item.value" :label="item.label" :value="item.value" ></el-option> </el-select> </el-form-item> </el-form> {{ watermarkStyle }} </div> <div class="main-right" id="show"> <div class="watermark"> <span :style="watermarkStyle" ref="showText" style="word-break:break-all;display: inline-block">{{ form.text }}</span> </div> </div> </div> </main-content> 左边来控制右边div里水印展示,代码怎么写

您可以在 `<el-form>` 标签上绑定 `@input` 事件,当表单数据发生改变时,触发该事件,然后在事件处理函数中计算出水印的样式,并将样式绑定到 `<span>` 标签上。具体实现代码如下: ``` <template> <main-content :ifDetail="true"> <div class="two-side"> <div class="main-left"> <el-form :model="form" :rules="rules" ref="form" label-width="120px" @input="handleInput"> <!-- 表单项省略 --> </el-form> </div> <div class="main-right" id="show"> <div class="watermark"> <span :style="watermarkStyle" ref="showText" style="word-break:break-all;display: inline-block">{{ form.text }}</span> </div> </div> </div> </main-content> </template> <script> export default { data() { return { form: { accountName: '', rotate: 0, text: '', fontSize: 16, alignment: 1, textPosition: 1 }, options: [ { label: '左上', value: 1 }, { label: '居中', value: 2 }, { label: '右下', value: 3 } ], textPositionOptions: [ { label: '正常', value: 1 }, { label: '斜体', value: 2 } ] } }, computed: { watermarkStyle() { const { rotate, fontSize, alignment, textPosition } = this.form const deg = rotate + (textPosition === 2 ? -45 : 0) const translateX = alignment === 1 ? '-10%' : alignment === 2 ? '-50%' : '90%' const translateY = alignment === 1 ? '-10%' : alignment === 2 ? '-50%' : '90%' const transform = `rotate(${deg}deg)` const style = { position: 'absolute', top: 0, left: 0, bottom: 0, right: 0, fontSize: `${fontSize}px`, transform: transform, '-webkit-transform': transform, '-ms-transform': transform, '-moz-transform': transform, '-o-transform': transform, opacity: '0.2', 'pointer-events': 'none', 'text-align': 'center', 'z-index': 9999, transformOrigin: '50% 50%', '-webkit-transform-origin': '50% 50%', '-ms-transform-origin': '50% 50%', '-moz-transform-origin': '50% 50%', '-o-transform-origin': '50% 50%', color: '#000', 'word-break': 'break-all', 'white-space': 'pre-wrap', 'max-height': '100%', 'max-width': '100%', overflow: 'hidden', 'text-overflow': 'ellipsis', '-webkit-text-fill-color': 'transparent', '-webkit-background-clip': 'text', 'background-clip': 'text', '-webkit-user-select': 'none', '-moz-user-select': 'none', '-ms-user-select': 'none', userSelect: 'none', '-webkit-line-clamp': '1', display: 'flex', 'align-items': 'center', 'justify-content': 'center', 'transform-style': 'preserve-3d' } if (textPosition === 2) { style.padding = '0.5rem' style.background = 'linear-gradient(to right bottom, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.2) 45%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.2) 55%, rgba(255, 255, 255, 0.2) 100%)' } style.transform += ` translate(${translateX}, ${translateY})` style['-webkit-transform'] += ` translate(${translateX}, ${translateY})` style['-moz-transform'] += ` translate(${translateX}, ${translateY})` style['-ms-transform'] += ` translate(${translateX}, ${translateY})` style['-o-transform'] += ` translate(${translateX}, ${translateY})` return style } }, methods: { handleInput() { this.$nextTick(() => { const { width, height } = this.$refs.show.getBoundingClientRect() const { offsetWidth, offsetHeight } = this.$refs.showText if (width === 0 || height === 0 || offsetWidth === 0 || offsetHeight === 0) { return } const scaleX = width / offsetWidth const scaleY = height / offsetHeight const scale = Math.min(scaleX, scaleY) this.$refs.showText.style.transform += `scale(${scale})` this.$refs.showText.style['-webkit-transform'] += `scale(${scale})` this.$refs.showText.style['-moz-transform'] += `scale(${scale})` this.$refs.showText.style['-ms-transform'] += `scale(${scale})` this.$refs.showText.style['-o-transform'] += `scale(${scale})` }) } } } </script> ``` 代码中的 `watermarkStyle` 计算属性用于计算水印的样式,`handleInput` 方法用于在计算出水印样式后,将水印按照比例缩小并居中显示。注意,为了保证水印样式的正确性,需要在表单项加载完成之后计算水印样式,因此需要在 `handleInput` 方法中使用 `$nextTick` 方法等待表单项加载完成再进行计算。

要求:每次点击放大/缩小 2个像素字号,最大到32,最小到12 --> <div> <button class="jia">+</button> <button class="jian">-</button> </div>

可以为您提供以下代码来实现这个功能: ```html <div> <button class="jia">+</button> <button class="jian">-</button> </div> <script> const fontSizeElement = document.querySelector('body'); let currentFontSize = 16; // 默认字体大小为16像素 const jiaButton = document.querySelector('.jia'); jiaButton.addEventListener('click', () => { if (currentFontSize < 32) { currentFontSize += 2; fontSizeElement.style.fontSize = `${currentFontSize}px`; } }); const jianButton = document.querySelector('.jian'); jianButton.addEventListener('click', () => { if (currentFontSize > 12) { currentFontSize -= 2; fontSizeElement.style.fontSize = `${currentFontSize}px`; } }); </script> ``` 将上述代码放置在您的 HTML 文件中,它会为页面上的 "+" 和 "-" 按钮添加点击事件监听器。每次点击 "+" 按钮时,字体大小将增加2像素(最大到32像素)。每次点击 "-" 按钮时,字体大小将减少2像素(最小到12像素)。 请将代码复制到您的项目中,并根据需要进行调整。希望对您有帮助!

相关推荐

<tui-drawer :mode="'bottom'" :visible="bottomDrawer" @close="closeDrawer"> <view class="d-container both"> <view class="drawer-title"> <view></view> <view style="font-weight: bold;">全部筛选</view> <gs-icon-text class="icon" icon="icon-chacha1" color="#535d73" fontSize="1.5em" @click="closeDrawer"></gs-icon-text> </view> <view> <gs-title title="办学性质" fontSize="30rpx"></gs-title> <view class="flex mb20 mt20" style="justify-content: space-between;"> <view class="education">公办</view> <view class="education">民办</view> </view> <gs-title class="mb20" title="等级" fontSize="30rpx"></gs-title> <view class="level" v-for="(item, index) in level" :key="index">{{ item }}</view> <gs-title class="mb35 mt35" title="类别" fontSize="30rpx"></gs-title> <view class="category" v-for="(item, index) in category" :key="index">{{ item }}</view> <view class="designatedMajors flex"> <gs-title class="mb35 mt35" title="单招专业" fontSize="30rpx"></gs-title> <gs-icon-text v-show="appoint != '指定专业'" icon="icon-right" fontSize="12px" color="#b6baca" iconPos="right" @click="designatedMajors">切换专业</gs-icon-text> </view> <view class="appoint" :class="{active:appoint != '指定专业'}" @click="designatedMajors">{{ appoint }}</view> <gs-title class="mb35 mt35" title="双高院校" fontSize="30rpx"></gs-title> <view style="margin-bottom: 150rpx;"> <view class="doubleheight" v-for="(item, index) in doubleheight" :key="index">{{ item.name }} <view>{{ item.level }}</view> </view> </view> </view> </view> <view class="tabbar"> <view class="resetting">重置</view> <view class="complete" @click="closeDrawer">完成</view> </view> </tui-drawer>onLoad((option) => { if (option.name) { bottomDrawer.value = true uni.pageScrollTo({ scrollTop:800 }) appoint.value = option.name } })如何在option.name为true的情况下让筛选滚动至单招专业上去

<ItemsControl x:Class="HDSProject.Control.CustomFont" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HDSProject.Control" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" x:Name="itemCtrl" ItemsSource="{Binding Path=Title2, RelativeSource={RelativeSource Mode=Self}}" FontSize="20" Foreground="Teal" > <ItemsControl.ItemContainerStyle> <Style TargetType="ContentPresenter"> <Setter Property="VerticalAlignment" Value="Center" /> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <Border Margin="{Binding Path=CharacterSpacing, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CustomFont}}"> <TextBlock Text="{Binding}" /> </Border> <Rectangle Height="1" Fill="{Binding Foreground, ElementName=itemCtrl}" Margin="0,0,0,5"> <Rectangle.Style> <Style TargetType="Rectangle"> <Setter Property="Visibility" Value="Collapsed" /> <Style.Triggers> <DataTrigger Binding="{Binding ShowUnderline, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CustomFont}}" Value="True"> <Setter Property="Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> </Rectangle.Style> </Rectangle> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>给这个自定义控件添加Thumb

<ItemsControl x:Class="HDSProject.Control.CustomFont" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HDSProject.Control" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" x:Name="itemCtrl" ItemsSource="{Binding Path=Title2, RelativeSource={RelativeSource Mode=Self}}" FontSize="20" Foreground="Teal" > <ItemsControl.ItemContainerStyle> <Style TargetType="ContentPresenter"> <Setter Property="VerticalAlignment" Value="Center" /> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <Border Margin="{Binding Path=CharacterSpacing, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CustomFont}}"> <TextBlock Text="{Binding}" /> </Border> <Rectangle Height="1" Fill="{Binding Foreground, ElementName=itemCtrl}" Margin="0,0,0,5"> <Rectangle.Style> <Style TargetType="Rectangle"> <Setter Property="Visibility" Value="Collapsed" /> <Style.Triggers> <DataTrigger Binding="{Binding ShowUnderline, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CustomFont}}" Value="True"> <Setter Property="Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> </Rectangle.Style> </Rectangle> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>给这个自定义控件添加Thumb

最新推荐

recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB图像处理算法宝典:从理论到实战

![MATLAB图像处理算法宝典:从理论到实战](https://img-blog.csdnimg.cn/20200717112736401.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d1emhhbzk5MDE=,size_16,color_FFFFFF,t_70) # 1. MATLAB图像处理基础理论 MATLAB图像处理是一种利用MATLAB编程语言进行图像处理的强大工具。它提供了丰富的函数和工具箱,用于图像获取、增强、分
recommend-type

matlab中1/x的非线性规划

在MATLAB中,可以使用非线性规划函数(`fmincon`)来优化一个包含1/x的非线性目标函数。下面是一个简单的例子: ```matlab % 定义目标函数 fun = @(x) 1/x; % 定义约束函数(这里没有约束) nonlcon = []; % 定义初始点 x0 = 1; % 定义优化选项 options = optimoptions('fmincon', 'Display', 'iter'); % 进行非线性规划 [x, fval] = fmincon(fun, x0, [], [], [], [], [], [], nonlcon, options); ``` 在
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

MATLAB数据可视化黑科技:洞悉数据背后的秘密

![MATLAB数据可视化黑科技:洞悉数据背后的秘密](https://img-blog.csdnimg.cn/img_convert/1a36558cefc0339f7836cca7680c0aef.png) # 1. MATLAB数据可视化的基本原理 MATLAB数据可视化是一种将数据转化为图形表示形式的技术,以帮助人们理解和分析数据。其基本原理包括: - **数据表示:**将原始数据转换为图形元素,如点、线和条形。 - **图形布局:**确定图形元素在绘图区域中的位置和大小。 - **图形美化:**添加标题、标签、颜色和纹理等元素,以增强图形的可读性和美观性。 - **交互性:**允
recommend-type

优化算法计算单位面积年平均输出热功率的代码

计算单位面积年平均输出热功率的代码具体情况取决于你所要解决的问题和需要的数据。然而,我可以给你一个通用的优化算法的框架,你可以根据具体情况进行调整。 首先,你需要明确计算单位面积年平均输出热功率的数学公式或算法。假设你已经有了计算热功率的函数 `calculate_power`,它接受一些输入参数,并返回热功率值。 下面是一个示例的优化算法框架,以最大化单位面积年平均输出热功率为目标: ```python import random def objective_function(params): # 这个函数用于计算目标函数的值 # 根据具体情况,你需要将 params
recommend-type

c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf

校园超市商品信息管理系统课程设计旨在帮助学生深入理解程序设计的基础知识,同时锻炼他们的实际操作能力。通过设计和实现一个校园超市商品信息管理系统,学生掌握了如何利用计算机科学与技术知识解决实际问题的能力。在课程设计过程中,学生需要对超市商品和销售员的关系进行有效管理,使系统功能更全面、实用,从而提高用户体验和便利性。 学生在课程设计过程中展现了积极的学习态度和纪律,没有缺勤情况,演示过程流畅且作品具有很强的使用价值。设计报告完整详细,展现了对问题的深入思考和解决能力。在答辩环节中,学生能够自信地回答问题,展示出扎实的专业知识和逻辑思维能力。教师对学生的表现予以肯定,认为学生在课程设计中表现出色,值得称赞。 整个课程设计过程包括平时成绩、报告成绩和演示与答辩成绩三个部分,其中平时表现占比20%,报告成绩占比40%,演示与答辩成绩占比40%。通过这三个部分的综合评定,最终为学生总成绩提供参考。总评分以百分制计算,全面评估学生在课程设计中的各项表现,最终为学生提供综合评价和反馈意见。 通过校园超市商品信息管理系统课程设计,学生不仅提升了对程序设计基础知识的理解与应用能力,同时也增强了团队协作和沟通能力。这一过程旨在培养学生综合运用技术解决问题的能力,为其未来的专业发展打下坚实基础。学生在进行校园超市商品信息管理系统课程设计过程中,不仅获得了理论知识的提升,同时也锻炼了实践能力和创新思维,为其未来的职业发展奠定了坚实基础。 校园超市商品信息管理系统课程设计的目的在于促进学生对程序设计基础知识的深入理解与掌握,同时培养学生解决实际问题的能力。通过对系统功能和用户需求的全面考量,学生设计了一个实用、高效的校园超市商品信息管理系统,为用户提供了更便捷、更高效的管理和使用体验。 综上所述,校园超市商品信息管理系统课程设计是一项旨在提升学生综合能力和实践技能的重要教学活动。通过此次设计,学生不仅深化了对程序设计基础知识的理解,还培养了解决实际问题的能力和团队合作精神。这一过程将为学生未来的专业发展提供坚实基础,使其在实际工作中能够胜任更多挑战。
recommend-type

关系数据表示学习

关系数据卢多维奇·多斯桑托斯引用此版本:卢多维奇·多斯桑托斯。关系数据的表示学习机器学习[cs.LG]。皮埃尔和玛丽·居里大学-巴黎第六大学,2017年。英语。NNT:2017PA066480。电话:01803188HAL ID:电话:01803188https://theses.hal.science/tel-01803188提交日期:2018年HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaireUNIVERSITY PIERRE和 MARIE CURIE计算机科学、电信和电子学博士学院(巴黎)巴黎6号计算机科学实验室D八角形T HESIS关系数据表示学习作者:Ludovic DOS SAntos主管:Patrick GALLINARI联合主管:本杰明·P·伊沃瓦斯基为满足计算机科学博士学位的要求而提交的论文评审团成员:先生蒂埃里·A·退休记者先生尤尼斯·B·恩