• 【原创】【滑块验证码】


    npm i vue-monoplasty-slide-verify

    main.js引入

    import SlideVerify from 'vue-monoplasty-slide-verify'
    Vue.use(SlideVerify)
     
    父组件
    <slide-verify ref="slideverify"></slide-verify>
    import slideVerify from "./slide-verify"
     
    子组件
    <template>
      <div style=" 100%; overflow: hidden">
        <slide-verify
          ref="slideblock"
          @again="onAgain"
          @fulfilled="onFulfilled"
          @success="onSuccess"
          @fail="onFail"
          @refresh="onRefresh"
          :slider-text="text"
          :accuracy="accuracy"
        ></slide-verify>
        <button @click="handleClick">在父组件可以点我刷新哦</button>
        <div>{{ msg }}</div>
      </div>
    </template>

    <script>
    export default {
      name: "slide",
      data() {
        return {
          msg: "",
          text: "向右滑动->",
          // 精确度小,可允许的误差范围小;为1时,则表示滑块要与凹槽完全重叠,才能验证成功。默认值为5
          accuracy: 1,
        };
      },
      methods: {
        onSuccess(times) {
          console.log("验证通过,耗时" + times + "毫秒");
          let time = (times / 1000).toFixed(1);
          let msg = "login success, 耗时" + time + "s";
          this.msg = msg;
        },
        onFail() {
          console.log("验证不通过");
          this.msg = "";
        },
        onRefresh() {
          console.log("点击了刷新小图标");
          this.msg = "";
        },
        onFulfilled() {
          console.log("刷新成功啦!");
        },
        onAgain() {
          console.log("检测到非人为操作的哦!");
          this.msg = "try again";
          this.$refs.slideblock.reset();
        },
        handleClick() {
          this.$refs.slideblock.reset();
        },
      },
    };
    </script>
  • 相关阅读:
    pyhon3 mysql的下载和配置
    python3 进程池和线程池
    python3 udp socketserver
    python3 多进程实现socket通讯
    python3 在一个进程内开启多个线程实现socket通讯
    python3 单线程(gevent)实现并发的socket通讯
    python3 协程gevent模块(遇到IO自动切换)
    python3 greenlet模块
    python3 协程函数yeild
    python3 线程队列queue
  • 原文地址:https://www.cnblogs.com/Forever-0209/p/14972505.html
Copyright © 2020-2023  润新知