【新增全局密码框】

新增全局密码框
vue

<template>
  <section id="page-password" v-if="visible">
    <section class="container">
      <label for=""><input v-model="password" type="text" placeholder="请输入密码"/></label>
      <button @click="submit">解锁</button>
    </section>
  </section>
</template>

<script>
// 引入控制密码层显示的变量,结合路由一起控制该层显示
import { pageVisiblePassword, blackList } from './PagePassword.ts';
export default {
  created() {
    this.visible = true;
  },
  data() {
    return {
      password: '',
      visible: true
    };
  },
  methods: {
    submit() {
      const pwd = this.password;
      if (pwd === pageVisiblePassword.pwd) {
        this.visible = false;
        this.password = '';
      }
    }
  }
};
</script>

<style lang="scss" scoped>
#page-password {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;

  .container {
    position: relative;
    z-index: 1001;

    label {
      input {
        text-align: center;
        height: 25px;
        outline: none;
        border: 1px solid #359c9c;
        border-radius: 5px;
      }
    }

    button {
      margin-left: 20px;
      height: 25px;
      width: 50px;
      color: #fff;
      background-color: #1b5f82;
      border: 1px solid rgb(77, 77, 155);
      border-radius: 3px;
    }
  }
}
</style>

ts

interface PageVisiblePassword {
  pwd: string;
  visible: boolean;
}

export const pageVisiblePassword: PageVisiblePassword = {
  pwd: 'Mt97@!Tom',
  visible: false
};

export const blackList: string[] = ['/login', '/home'];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值