(1)input 限制输入,小数点后保留两位
<template><div><el-input v-model="number" @input="checkNumber" @blur="completeNumber" placeholder="请输入"></el-input></div>
</template><script>
export default {data() {return {number: '' // 初始值为空字符串}},methods: {checkNumber(value) {let number = value.replace(/[^\d.]/g, '') // 清除“数字”和“.”以外的字符.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的.replace(/^(-)*(\d+)\.(\d{0,2}).*$/, '$1$2.$3'); // 只能输入两个小数this.number = number;},completeNumber() {let number = this.number.trim(); // 去掉前后空格if (!number) {this.number = ''; // 如果数字为空,则清空输入框return; // 如果数字为空,不继续进行后续操作}let value = number;number = parseFloat(number).toFixed(2); // 将数字转换为浮点数再转换回字符串,去掉前导零if (number < 0 || number > 100) {this.$message.error({message: '输入的范围应为0-100%',duration: 400});this.number = undefinedreturn}// 判断价格小数部分是否需要补全const needsCompletion = !/\.\d{2}$/.test(value)this.number = number;// 如果需要补全,则提示用户if (needsCompletion) {this.$message.info({message: '数字已自动补全为两位小数。',duration: 400});}}}
}
</script><style scoped>
/* Add your styles here if needed */
</style>
推荐和参考文章:Vue input 限制输入正负数,小数点后保留两位_vue中input输入金额小数点后两位之后就不能输入了-CSDN博客文章浏览阅读3.1k次,点赞2次,收藏4次。Vue input 限制输入正负数,小数点后保留两位_vue中input输入金额小数点后两位之后就不能输入了https://blog.csdn.net/weixin_44021888/article/details/127065250
(2) 图片垂直居中显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vertical Center Image</title>
<style>
.div-container {position: relative;width: 80px;height: 67px;background-color: lightgray;
}.image-holder {position: absolute;top: 11px;left: 0;width: 80px;height: 45px;display: flex;justify-content: center;
}.image-holder img {max-width: 100%;max-height: 100%;margin: auto;
}
</style>
</head>
<body>
<div class="div-container"><div class="image-holder"><img src="E:\hehedaWork\test\girl.jpg" alt="Your Image" /></div>
</div>
</body>
</html>
error: Your local changes to the following files would be overwritten by merge:(有未提交的文件 git pull冲突解)
如果你本地有修改,然后也不好提交,又需要pull远程的代码到本地,你可以在本地先执行一下:
- git stash,
- 然后git pull ,
- 再然后git stash pop就可以了
- 然后你就在tortoiseGit上commit,再push
推荐和参考文章:error:Your local changes to the following files would be overwritten by merge:_error: your local changes to the following files w-CSDN博客文章浏览阅读2.1k次。error:Your local changes to the following files would be overwritten by merge:1. 用git pull来更新代码的时候,遇到了以下报错信息:error:Your local changes to the following files would be overwritten by merge: xxx/xxx/xxx.vue Please, commit your changes or stash them before y_error: your local changes to the following files would be overwritten by merhttps://blog.csdn.net/StoneVivi/article/details/114809766
error: Your local changes to the following files would be overwritten by merge:(有未提交的文件 git pull冲突解)-CSDN博客文章浏览阅读5.7k次,点赞5次,收藏7次。这个错误通常发生在你尝试将远程分支合并到本地分支时,但你的本地分支上存在未提交的更改。Git会阻止合并操作,以防止你的未提交更改被覆盖。_error: your local changes to the following files would be overwritten by merhttps://blog.csdn.net/weixin_43637980/article/details/132468627
情况一:合并主干的时候出现冲突,解决冲突:
git fetch
git rebase origin/master
git rebase --continue
git push --force
情况二:当本地的已经乱了,但是远端的master已经合并了你最后一次的代码,此时你可以先把你本地修改的文件先拷贝一份出来,然后让远端的master的代码强行覆盖掉当前的目录内容。弄好之后再把文件拷贝进去
在当前分支git fetch然后 git checkout master (旧的)可以查看一下日志 git log拉取最新的 git pull可以查看一下日志 git log (新的)git reset --hard orgin/master可以查看一下日志 git log最后 把更新过的且当做备份的文件拷贝替换一下,如果有冲突,就文本对比一下,解决一下就好了