zoukankan      html  css  js  c++  java
  • 如何和后端进行图片验证码的交互?

    现在很多项目都有进行图片验证码验证的功能,今天我也碰到了,遇到一个大坑:

      普通的接口请求我们都会拿到后端返回的结果进行一系列操作,但是图片验证码,后端不给你返回任何数据;

      所以这个坑就是,图片验证码的接口就是你页面中img标签绑定的src

    <template>
      <div class="globalSet" style="min- 824px;calc(100% - 10px - 10px);height:calc(100% - 10px - 10px);color:red;">
        <div @click="refresh">换一张 </div>
        <img :src="imgSrc" style="100px;height:50px">
      </div>
    </template>
    
    <script>
    export default {
      name: "globalSet1",
    
      data() {
        return {
          imgSrc: window.$url_front.serverBcsUrl + "/openRegister/createImagecode"
        };
      },
      methods: {
        refresh() {
          var num = Math.ceil(Math.random() * 10); //生成一个随机数(防止缓存)
          this.imgSrc = window.$url_front.serverBcsUrl + "/openRegister/createImagecode?id=" + num;
        }
      }
    };
    </script>
    

      

     

       

  • 相关阅读:
    MongoDB学习笔记(查询)
    PHP IP地址转换
    PHP SESSION的工作原理解析(转)
    JavaScript 之 RegExp 对象
    jquery 几个实用的小方法
    JS之document.cookie随笔
    CodeForces
    CodeForces
    翻转 -- CodeForces
    Codeforces --- 982C Cut 'em all! DFS加贪心
  • 原文地址:https://www.cnblogs.com/wangqi2019/p/12627330.html
Copyright © 2011-2022 走看看