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

怎么把网站设置为主页面装潢设计培训中心

怎么把网站设置为主页面,装潢设计培训中心,广东成都网站建设推广公司,metro风格网站开发vue2 elementUI 登录页面实现回车提交登录的方法 方法一 局部回车事件 在el-form 上增加 keyup.enter.native“login”,当焦点在form中任意控件上时,按回车事件生效。 方法二 全局回车事件 增加生命周期函数mounted()注册监听事件(addE…

vue2 elementUI 登录页面实现回车提交登录的方法

方法一

局部回车事件

在el-form 上增加 @keyup.enter.native=“login”,当焦点在form中任意控件上时,按回车事件生效。

方法二

全局回车事件

增加生命周期函数mounted()注册监听事件(addEventListener)和beforeDestroy()销毁监听事件(removeEventListener),在method中自定义函数globalKeyupHandler(event) ,在其中响应事件即可。

实现方法请参照如下源码

<template><div class="login"><div class="box"><div class="chunk"><span>欢迎登录</span><p>{{ store.sys.company }}</p></div><div class="form"><div class="title"><span>{{ store.sys.name }}</span><small>{{ store.sys.slogan }}</small></div><el-form :model="form" :rules="rules" ref="form"  @keyup.enter.native="login"><el-form-item prop="user"><el-input size="medium" type="text" v-model="form.user" prefix-icon="el-icon-user" placeholder="请输入用户账号|手机号"autofocus clearable></el-input></el-form-item><el-form-item prop="pwd"><el-input size="medium" type="password" v-model="form.pwd" prefix-icon="el-icon-lock" placeholder="请输入用户密码"show-password clearable></el-input></el-form-item><el-form-item class="captchaGroup" pro="captcha"><el-row :gutter="10"><el-col :span="13"><el-input size="medium" type="text" v-model="form.captcha" prefix-icon="el-icon-key"placeholder="请输入验证码" clearable></el-input></el-col><el-col :span="10"><img title="点击可刷新验证码" ref="captcha" @click="getCaptcha"></img></el-col></el-row></el-form-item><el-button size="medium" type="primary" class="btn" @click="login">安全登录</el-button><p class="tip">{{ store.sys.notice_login }}</p></el-form></div></div><div class="footer">ERP {{ store.base.ver }} | Copyright ©<a :href="store.base.webSite" target="_blank">{{store.base.copyright}}</a><a href="https://beian.miit.gov.cn/" target="_blank" style="margin-left:10px;">{{store.sys.icp}}</a><!-- <a  style="height: 24px; margin-left: 10px;"  href='https://gitee.com/ntlhqk' target="_blank"><img src='https://gitee.com/star.svg?theme=dark' alt='star'></img></a> --></div></div>
</template>
<script>
export default {name: "Login",data() {return {form: {user: "",pwd: "",uuid: "",},rules: {user: {required: true,message: "请输入用户账号|手机号",trigger: "blur",},pwd: {required: true,message: "请输入用户密码",trigger: "blur",},},};},created() {//获取运行数据this.getCaptcha();this.getRunData();},computed: {store() {return this.$store.state;},},mounted() {window.addEventListener('keyup', this.globalKeyupHandler);},beforeDestroy() {window.removeEventListener('keyup', this.globalKeyupHandler);},methods: {globalKeyupHandler(event) {if (event.key === 'Enter') {// 触发登录// this.login();}},getCaptcha() {this.$axios.post("api/captcha", this.form).then((result) => {if (result.state == "success") {this.form.code = "";this.form.uuid = result.info.uuid;this.$refs.captcha.src = result.info.data;} else if (result.state == "error") {this.$message({type: "warning",message: result.info,});} else {this.$message({type: "error",message: "[ ERROR ] 服务器响应超时!",});}});},//登录login() {this.$refs["form"].validate((valid) => {if (valid) {this.$axios.post("api/login", this.form).then((result) => {if (result.state == "success") {this.$store.commit("upState", {key: "user",val: result.info,});this.$store.commit("upState", {key: "token",val: result.token,});this.$router.push("/home");} else if (result.state == "error") {this.$message({type: "warning",message: result.info,});} else {this.$message({type: "error",message: "[ ERROR ] 服务器响应超时!",});}});}});},//获取运行数据getRunData() {this.$axios.post("api/runData").then((result) => {if (result.state == "success") {this.$store.commit("upState", {key: "sys",val: result.info.sys,});this.$store.commit("upState", {key: "base.ver",val: result.info.ver,});if (result.info.login == true) {this.$router.push("/home");}} else if (result.state == "error") {this.$message({type: "warning",message: result.info,});} else {this.$message({type: "error",message: "[ ERROR ] 服务器响应超时!",});}});},},
};
</script>
<style scoped>
.login {position: absolute;background: #2d3135;width: 100vw;height: 100vh;background: url(/static/images/login/bg.png);background-repeat: no-repeat;background-size: cover;
}.box {display: flex;width: 860px;height: 460px;margin: 0 auto;margin-top: 16vh;position: relative;z-index: 2;box-shadow: 0 0 16px 8px #1261c1;
}.form {flex: 1;background: #fff;padding: 62px 0;border-top-right-radius: 4px;border-bottom-right-radius: 4px;
}.title>span {font-size: 20px;display: block;text-align: center;color: #5c5f68;line-height: 36px;font-weight: bold;letter-spacing: 2px;
}.title>small {display: block;text-align: center;color: #888;line-height: 24px;letter-spacing: 1px;
}.form .el-form {width: 320px;margin: 0 auto;margin-top: 24px;
}.el-form-item {margin-bottom: 24px;
}.el-form>>>.el-form-item__error {padding: 4px 0;
}.captchaGroup {display: flex;display: none;
}.captchaGroup .el-input {margin-right: 12px;
}.captchaGroup img {width: auto;height: 36px;border: 1px solid #DDD;box-sizing: border-box;border-radius: 4px;cursor: pointer;
}.btn {width: 100%;
}.chunk {width: 320px;text-align: center;background: url("/static/images/login/chunk.png");background-repeat: no-repeat;background-size: cover;border-top-left-radius: 4px;border-bottom-left-radius: 4px;
}.chunk span {color: #fff;display: block;margin-top: 45%;font-size: 24px;line-height: 36px;
}.chunk p {color: #d1d1d1;line-height: 32px;font-size: 14px;
}.footer {position: absolute;left: 0;bottom: 0;width: 100%;color: #99afff;line-height: 36px;text-align: center;z-index: 2;display: flex;align-items: center;justify-content: center;
}.footer a {color: #99afff;
}.tip {margin-top: 18px;color: #5c5f68;font-size: 12px;
}@media screen and (max-width: 860px) {.box {margin: 0;width: 100vw;height: 100vh;}.chunk {display: none;}.form {padding: 0;border-radius: 0;}.title {background: url("/static/images/login/mobile.png");background-repeat: no-repeat;background-size: cover;height: 200px;padding: 60px 0;box-sizing: border-box;}.title>span {color: #fff;}.footer {font-size: 12px;color: #ccc;}.footer a {color: #ccc;}}
</style>
http://www.dtcms.com/a/430503.html

相关文章:

  • 好的html5网站快排seo
  • 软件ui设计培训机构下载班级优化大师并安装
  • 做装修的网站怎么做好中山做营销型网站公司
  • 网站建站行业新闻外链网站是什么
  • 邯郸网站设计报价山西省确诊病例最新情况
  • 网站方案组成要素昆明软件开发培训
  • 网站统计模板网站建设需求分析的实施
  • 旅游网站策划案苏宁网站开发人员工资
  • 做推广用的网站wordpress更换域名后显示空白
  • 建行移动门户网站有前景的网站建设
  • 电子商务网站建设的核心是wordpress连接被重置
  • 文章类型的网站模版恩施网站定制
  • 百度给做网站公司建筑企业官网
  • 网站 侧边栏惠安网站建设价格
  • 企业建设网站作用制作企业宣传片的厂家
  • 如何自己免费建网站网站开发网页
  • 网站开发去哪里找程序员网站 asp php
  • 厦门做网站个人wordpress 数据库 发布
  • 室内设计网站模板青岛网站建设方案公司
  • so域名的网站tk域名官网
  • phpcms网站title站长网网站模板下载
  • 湖州佳成建设网站定兴网站建设
  • 济南市公众号网站建设wordpress中文分词
  • 上线公司 企业网站免费做公司电子画册的网站
  • 公司做网站怎么赚钱吗设计 在线
  • 深圳排名网站wordpress 主题 相册
  • 中关村在线官方网站品牌建设的内容有哪些
  • 劳务输送网站建设方案咸阳专业网站开发哪家好
  • 那个旅游网站可以做行程网商之窗官网
  • 建设网站的主要流程哪个网站查企业信息免费