vue element-ui 下拉框 以及 input 限制输入,小数点后保留两位 界面设计案例 和 例子:支持mp4和m3u8视频播放

vue input 限制输入,小数点后保留两位 以及 图片垂直居中显示 和 分享 git 小技巧-CSDN博客文章浏览阅读430次,点赞5次,收藏4次。error:Your local changes to the following files would be overwritten by merge:_error: your local changes to the following files w-CSDN博客。情况二:当本地的已经乱了,但是远端的master已经合并了你最后一次的代码,此时你可以先把你本地修改的文件先拷贝一份出来,然后让远端的master的代码强行覆盖掉当前的目录内容。https://blog.csdn.net/weixin_41987016/article/details/139592956?spm=1001.2014.3001.5501(1)下拉框 以及 input 限制输入,小数点后保留两位 界面设计案例

<template><div class="info-settings"><el-form :model="formData" label-width="120px"><el-form-item label="类型:"><el-select v-model="formData.infoType" placeholder="请选择"><el-option label="周提醒" value="weekly"></el-option><el-option label="月提醒" value="monthly"></el-option></el-select></el-form-item><el-form-item label="提醒标准:"><div class="form-item"><el-button class="text-button self-button" plain disabled>就业率</el-button><el-select v-model="formData.thresholdOperator" placeholder="请选择" disabled><el-option label=">" value="greaterThan"></el-option><el-option label="<" value="lessThan"></el-option></el-select><el-input v-model="formData.thresholdValue" placeholder="请输入"@input="checkThresholdValue(formData.thresholdValue)" @blur="completeThresholdValue"><i slot="suffix" style="font-style:normal;margin-right: 10px;">%</i></el-input></div></el-form-item><el-form-item><div class="form-item"><el-button class="text-button self-button" plain disabled>GPD</el-button><el-select v-model="formData.GPDOperator" placeholder="请选择" disabled><el-option label=">" value="greaterThan"></el-option><el-option label="<" value="lessThan"></el-option></el-select><el-input v-model="formData.GPDValue" placeholder="请输入" @input="checkGPDValue(formData.GPDValue)"@blur="completeGPDValue"><i slot="suffix" style="font-style:normal;margin-right: 10px;">%</i></el-input></div></el-form-item><el-form-item><div class="form-item"><el-button class="text-button self-button" plain disabled>工资</el-button><el-select v-model="formData.revenueOperator" placeholder="请选择" disabled><el-option label=">" value="greaterThan"></el-option><el-option label="<" value="lessThan"></el-option></el-select><el-input v-model="formData.revenueValue" placeholder="请输入" @input="checkRevenueValue(formData.revenueValue)"@blur="completeRevenueValue"><i slot="suffix" style="font-style:normal;margin-right: 10px;">元</i></el-input></div></el-form-item><el-form-item label="提醒文案标题:"><el-input type="textarea" v-model="formData.infoMessage" placeholder="请输入提醒文案标题" maxlength="20" show-word-limit></el-input></el-form-item><el-form-item label="提醒文案内容:"><el-input type="textarea" v-model="formData.infoContent" placeholder="请输入提醒文案内容" maxlength="200" show-word-limit></el-input></el-form-item><el-form-item><el-button @click="cancel" class="medium-button">取消</el-button><el-button type="primary" @click="confirm" class="medium-button">确定</el-button></el-form-item></el-form></div>
</template><script>
export default {data() {return {formData: {infoType: 'weekly',thresholdOperator: 'greaterThan',thresholdValue: '',GPDOperator: 'lessThan',GPDValue: '',revenueOperator: 'greaterThan',revenueValue: '',infoMessage: '',infoContent: ''}};},methods: {cancel() {// 取消按钮的操作},confirm() {// 确定按钮的操作},checkThresholdValue(value) {this.formData.thresholdValue = this.checkNumber(value);},checkGPDValue(value) {this.formData.GPDValue = this.checkNumber(value);},checkRevenueValue(value) {this.formData.revenueValue = this.checkNumber(value);},checkNumber(value) {let number = value.replace(/[^\d.]/g, '') // 清除“数字”和“.”以外的字符.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的.replace(/^(-)*(\d+)\.(\d{0,2}).*$/, '$1$2.$3'); // 只能输入两个小数return number;},completeThresholdValue() {this.completeNumber('thresholdValue');},completeGPDValue() {this.completeNumber('GPDValue');},completeRevenueValue() {this.completeNumber('revenueValue');},completeNumber(field) {let value = this.formData[field].trim();if (!value) {this.formData[field] = ''; // 如果数字为空,则清空输入框return; // 如果数字为空,不继续进行后续操作}let number = parseFloat(value).toFixed(2); // 将数字转换为浮点数再转换回字符串,去掉前导零if ((number < 0 || number > 100) && field.toString() !== 'revenueValue') {this.$message.error({message: '输入的范围应为0-100%',duration: 400});this.number = undefinedreturn}// 判断价格小数部分是否需要补全const needsCompletion = !/\.\d{2}$/.test(value)this.formData[field] = number;// 如果需要补全,则提示用户if (needsCompletion) {this.$message.info({message: '数字已自动补全为两位小数。',duration: 400});}}}
};
</script><style scoped>
.info-settings .el-form-item__content {display: flex;align-items: center;
}.info-settings .el-input__suffix {font-size: 14px;
}.form-item {display: flex;align-items: center;margin-bottom: 10px;/* 添加下方间距 */
}.form-item>* {margin-right: 10px;
}.text-button {color: #909399;font-size: 14px;
}.self-button {min-width: 80px;/* 设置按钮最小宽度 */color: #000000;/* 设置按钮文字颜色为黑色 */display: flex;justify-content: center;/* 文本水平居中 */align-items: center;/* 文本垂直居中 */
}.medium-button {width: 80px;/* 设置按钮宽度 */
}</style>
<style>
.el-textarea__inner::-webkit-scrollbar {width: 6px;height: 6px;
}.el-textarea__inner::-webkit-scrollbar-thumb {border-radius: 3px;-moz-border-radius: 3px;-webkit-border-radius: 3px;background-color: #c3c3c3;
}.el-textarea__inner::-webkit-scrollbar-track {background-color: transparent;
}
</style>

(2)点击表格中的图片,可以查看,图片可以垂直水平居中放在表格中

<template><div><el-table :data="tableData" :cell-style="{ textAlign: 'center' }" :header-cell-style="{ textAlign: 'center' }"><el-table-column prop="name" label="Name"></el-table-column><el-table-column prop="age" label="Age"></el-table-column><el-table-column prop="gender" label="Gender"></el-table-column><el-table-column label="Cover" align="center" class="no-padding"><template slot-scope="scope"><div class="cover-wrapper"><el-image class="cover-image" :src="require('@/assets/cover_test.png')" style="object-fit: cover;"@click="showImage(scope.row.cover)"></el-image></div></template></el-table-column></el-table><!-- 图片查看器 --><div v-if="isImageViewerOpen" class="image-overlay" @click="hideImageViewer"><el-image :src="currentImage" class="image-viewer"></el-image></div></div>
</template><script>export default {data() {return {tableData: [{ name: 'John', age: 30, gender: 'Male', cover: require('@/assets/cover_test.png') },{ name: 'Jane', age: 25, gender: 'Female', cover: require('@/assets/cover_test.png') },// Add more data as needed],isImageViewerOpen: false,currentImage: '',viewerVisible: false};},methods: {showImage(image) {this.currentImage = image;this.isImageViewerOpen = true;this.viewerVisible = true;},hideImageViewer() {this.isImageViewerOpen = false;}}
};
</script><style scoped>
/* .cover-wrapper {position: relative;overflow: hidden;}.cover-image {width: 80px;height: 45px;cursor: pointer;} */
.image-overlay {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background: rgba(0, 0, 0, 0.7);z-index: 9999;display: flex;justify-content: center;align-items: center;
}.image-viewer {max-width: 90%;max-height: 90%;
}
</style><style scoped>
.cover-wrapper {position: relative;overflow: hidden;
}.el-table .cover-image-show {width: 80px;top: 2.5px;height: 45px;cursor: pointer;
}/* 将表格中带有no-padding类的单元格的padding设置为0 */
.el-table /deep/ .cell {padding: 0;
}
</style>

(3)支持mp4和m3u8视频播放 

<template><div><el-button @click="openDialog('http://ai-xxxxxxxx_34.m3u8', 1)" type="primary">Open Video 1 (.m3u8)</el-button><el-button @click="openDialog('http://tx-xxxx.mp4', 2)" type="primary">Open Video 2 (.mp4)</el-button><el-button @click="openDialog('', 3)" type="primary">Unable to play.</el-button><el-button @click="openDialog('http://tx-xx.cdn.xxx.com/2422/12233421/', 3)" type="primary">err Link</el-button><el-dialogv-if="showDialog":visible.sync="showDialog":title="'Video ' + currentPlayerId"@close="closeDialog"width="720px"class="video-dialog"><div v-if="videoError"><p>{{ videoError }}</p></div><video :id="'videoPlayer' + currentPlayerId" :class="videoClass" style="width: 100%;" controls preload="auto" :width="videoWidth" ></video></el-dialog></div>
</template><script>
import videojs from 'video.js';
import 'video.js/dist/video-js.css';export default {data() {return {showDialog: false,currentPlayerId: null,videoPlayer: null,videoError: null,videoWidth: '720px', // Default widthvideoHeight: '450px', // Default heightvideoClass: 'video-js vjs-default-skin vjs-big-play-centered' // Default class};},methods: {openDialog(url, playerId) {this.showDialog = true;this.currentPlayerId = playerId;this.videoError = null;// Wait for next tick to ensure the element is mounted before initializing Video.jsthis.$nextTick(() => {this.initVideoPlayer(url);});},closeDialog() {if (this.videoPlayer) {this.videoPlayer.dispose();this.videoPlayer = null;}this.showDialog = false;this.currentPlayerId = null;this.videoError = null;},initVideoPlayer(url) {this.videoPlayer = videojs('videoPlayer' + this.currentPlayerId, {html5: {hls: {overrideNative: true}},playbackRates: [0.5, 1, 1.5, 2]});this.videoPlayer.on('error', (error) => {console.error('Video playback error:', error);this.videoError = 'Unable to play the video.';});const type = this.getVideoType(url);if (type === 'video/mp4') {this.videoPlayer.src({src: url,type: 'video/mp4'});} else if (type === 'application/x-mpegURL') {this.videoPlayer.src({src: url,type: 'application/x-mpegURL'});}this.videoPlayer.ready(() => {// 忽略未使用的变量/* eslint-disable no-unused-vars */// const videoEl = document.getElementById('videoPlayer' + this.currentPlayerId);// const aspectRatio = this.videoPlayer.videoWidth() / this.videoPlayer.videoHeight();// this.videoWidth = 720;// this.videoHeight = this.videoWidth / aspectRatio;// videoEl.style.height = `${this.videoHeight}px`;this.videoPlayer.play();});},getVideoType(url) {const extension = url.toLowerCase().includes('.mp4') ? 'mp4' : 'm3u8';if (extension === 'mp4') {return 'video/mp4';} else if (extension === 'm3u8') {return 'application/x-mpegURL';} else {return '';}}},beforeDestroy() {if (this.videoPlayer) {this.videoPlayer.dispose();this.videoPlayer = null;}}
};
</script><style>
/* Add any custom styles for the video player here */
.video-dialog {.el-dialog__header {border-bottom: none;}.el-dialog__body {padding: 0;}/*.dialog-content {padding:0 40px;}.el-dialog__footer {padding: 10px 10px 10px;border-top: none;} */
}</style>

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

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

相关文章

Python 介绍——浔川python社

python简介 Python是一种高级、通用的编程语言&#xff0c;由Guido van Rossum于1989年创建。它被设计为易于阅读和理解&#xff0c;并且具有简洁的语法&#xff0c;使得开发人员能够更快地编写代码。 Python被广泛用于不同的领域&#xff0c;包括Web开发、数据分析、人工智能…

2024.6.18 作业 xyt

今日作业&#xff1a; 1. 完善对话框&#xff0c;点击登录对话框&#xff0c;如果账号和密码匹配&#xff0c;则弹出信息对话框&#xff0c;给出提示”登录成功“&#xff0c;提供一个Ok按钮&#xff0c;用户点击Ok后&#xff0c;关闭登录界面&#xff0c;跳转到其他界面 如果…

广东省省站节能检测试题库(2024年)

1.外墙外保温系统耐候性试验设备,测温点不应少于( ),每个测温点的温度与平均温度偏差不应大于( )。 A、2个,5℃ B、4个,5℃ C、2

未来谁主沉浮? / 全能AI模型的发展趋势和展望

在近日腾讯元宝APP的正式上线后&#xff0c;国内大模型产品如雨后春笋般涌现&#xff0c;引发了广泛的关注。在这股AIGC&#xff08;人工智能生成内容&#xff09;的热潮中&#xff0c;我也体验过不少全能型的大模型产品。那么&#xff0c;这些产品有哪些优缺点呢&#xff1f;在…

C++ 64 之 函数模版和普通函数调用规则

#include <iostream> #include <string> using namespace std;template<typename T> void myPrint(T a, T b){cout << "函数模板的调用" << endl; }void myPrint(int a, int b){cout << "普通函数调用" << endl…

C#——只读属性readonly

只读属性readonly 类的字段可以通过一个readonly(只读)表示这个为只读字段&#xff0c;不能被构造函数之外地方进行修改&#xff0c;静态只读字段不能在非静态的构造函数中使用 定义 只读属性的特点&#xff1a; 字段是只读的非静态 只能在非静态方法中进行修改 字段是只读的…

如何使用芯片手册做软件开发?

在阅读和利用芯片手册进行软件开发时&#xff0c;你应该关注以下几个关键点&#xff1a; 引脚功能&#xff1a;了解芯片上每个引脚的功能&#xff0c;包括它们可以被配置为输入还是输出&#xff0c;以及它们支持的特殊功能&#xff0c;如模拟输入、PWM输出、中断等。 寄存器映…

NoSQL-Tidis支持分布式事务,兼容redis协议,使用tikv存储引擎,可水平扩展

项目repo地址 GitHub - yongman/tidis: Distributed transactional NoSQL database, Redis protocol compatible using tikv as backend Tidis是分布式数据库,支持redis协议,多种数据结构支持,编写语言为golang。 Tidis工作角色类似于TIDB,提供协议转换和数据结构计算,底…

RockChip Android12 System之Datetime

一:概述 本文将针对Android12 Settings二级菜单System中Date&time的UI修改进行说明。 二:Date&Time 1、Activity packages/apps/Settings/AndroidManifest.xml <activityandroid:name="Settings$DateTimeSettingsActivity"android:label="@stri…

JavaFX选择框

JavaFX选择框允许用户在几个选项之间快速选择。 创建一个选择框 我们可以使用ChoiceBox中的构造函数来创建ChoiceBox对象。 以下代码显示了如何使用其构造函数创建和填充选择框。 列表项是从可观察的列表来创建的。 ChoiceBox cb newChoiceBox(FXCollections.observableArra…

音频处理2_进阶概念

本节主要对”音乐”和”人声“等概念初步整理&#xff0c;并过度到AI模型的讲解&#xff0c;本节后续会有补充或修改。 1. 名词概念 1.1 音频类 基频&#xff08;f0&#xff09; 复杂声音&#xff08;例如人声、乐器音&#xff09;通常由多个频率成分组成。基频是最低的频率成…

Unity基础(三)3D场景搭建

目录 简介: 一.下载新手资源 二.创建基本地形 三.添加场景细节 四,添加水 五,其他 六. 总结 简介: 在 Unity 中进行 3D 场景搭建是创建富有立体感和真实感的虚拟环境的关键步骤。 首先&#xff0c;需要导入各种 3D 模型资源&#xff0c;如建筑物、角色、道具等。这些模…

springboot与flowable(9):候选人组

act_id_xxx相关表存储了所有用户和组的数据。 一、维护用户信息 Autowiredprivate IdentityService identityService;/*** 维护用户*/Testvoid createUser() {User user identityService.newUser("zhangsan");user.setEmail("zhangsanqq.com");user.setF…

TOP150-LC45-跳跃问题II-java版

java解法-贪心 /*跳跃游戏II 给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]。每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说&#xff0c;如果你在 nums[i] 处&#xff0c;你可以跳转到任意 nums[i j] 处:0 < j < nums[i]i j < n 返…

一周刷爆leetcode!(b站视频)

文章目录 一、排序思想的题目二、使用步骤1. 一、排序思想的题目 跟着b站一周刷爆leetcode这个视频开始刷一下leetcode的题目 进行一下记录啥的 二、使用步骤 1. 315. 计算右侧小于当前元素的个数 代码如下&#xff1a; 写了一下暴力解法&#xff0c;没有通过 使用归并排序…

CHATGPT说这个运算放大器是比较器,我说这是运放典型的同相比例放大器,一个光控电路分析

纠正 图1 光控电路 该电路来自一个问题&#xff0c;链接见文末。 因GPT的分析有误&#xff0c;特此纠正。 引用图片和答案用于分析&#xff0c;如侵权请联系本人。 电路分析&#xff1a; 该电路为光控灯电路&#xff0c;灯光为LED发光二极管 D。 光敏电阻RG的阻值和光线强度关…

6.18作业

完善对话框&#xff0c;点击登录对话框&#xff0c;如果账号和密码匹配&#xff0c;则弹出信息对话框&#xff0c;给出提示”登录成功“&#xff0c;提供一个Ok按钮&#xff0c;用户点击Ok后&#xff0c;关闭登录界面&#xff0c;跳转到其他界面 如果账号和密码不匹配&#xf…

翻转数位00

题目链接 翻转数位 题目描述 注意点 可以将一个数位从0变为1找出能够获得的最长的一串1的长度&#xff08;必须是连续的&#xff09; 解答思路 参照题解使用动态规划解决本题&#xff0c;对于任意一个位置i&#xff0c;dp[i][0]表示到达且包含第i位不翻转0最长1的长度&…

使用 rosbag play 更改bag包发布的话题名称

在ROS开发中&#xff0c;有时我们需要回放已记录的ROS包文件&#xff08;.bag&#xff09;&#xff0c;并将其中某个话题的数据重新映射到一个新的话题。这在数据处理、调试和系统集成时非常有用。例如&#xff0c;我们可能有一个记录了点云数据的ROS包文件&#xff0c;其中点云…

Git 拉取指定分支 合并入主分支

前提条件 确保你已经安装了Git&#xff0c;并且已经克隆了自己的仓库到本地。 解决方法 添加远程仓库 假设你已经添加了远程仓库&#xff1a; git remote add upstream https://github.com/username/repo.git 获取远程仓库的分支 获取远程仓库的所有分支信息&#xff1a; g…