< el-input v-model=「loginform.verifycode」 placeholder=「請輸入驗證碼」 class=「identifyinput」 style=「width:150px;」>< /el-input>
< div class=「identifybox」>
< div @click=「refreshcode」>
< s-identify :identifycode=「identifycode」>< /s-identify>
< /div>
看不清,換一張< /el-button>
< /div>
< /el-form-item>
import sidentify from 『@/components/authcode/index.vue』 //驗證碼需要用到的生成類
//驗證碼需要用到的生成類
< template>
< div class=「s-canvas」>
< canvas id=「s-canvas」 :width=「contentwidth」 :height=「contentheight」>
< script>
export default ,
fontsizemin: ,
fontsizemax: ,
backgroundcolormin: ,
backgroundcolormax: ,
colormin: ,
colormax: ,
linecolormin: ,
linecolormax: ,
dotcolormin: ,
dotcolormax: ,
contentwidth: ,
contentheight:
},methods: ,
// 生成乙個隨機的顏色
randomcolor(min, max) ,
drawpic()
},drawtext(ctx, txt, i) ,
drawline(ctx)
},drawdot(ctx) }},
watch:
},mounted()
}< /script>
//驗證碼需要用到的生成類
export default ,
data() else
}const validatepassword = (rule, value, callback) => else else}}
// 驗證碼自定義驗證規則
const validateverifycode = (rule, value, callback) => else if (value !== this.identifycode) else
}return ,
checked: false,
loginrules: ],
password: ,
verifycode: },
}},mounted() ,
created()
}let accounts=this.getcookie(「account」)
if(accounts)
},methods: ,
// 切換驗證碼
refreshcode() ,
// 生成四位隨機驗證碼
makecode(o, l)
},handlelogin() ', got 'eof' at end of input: … this.store.dispatch(『user/login』, this.loginform).then(() => )
this.loading = false
}).catch(() => )
} else
})},
// 儲存cookie
setcookie: function (cname, value, expiredays) ,
// 獲取cookie
getcookie: function (key)
}return 『』},}
驗證碼隨機生成
pip install captcha驗證碼隨機生成 python 版本 3.6 captcha 版本 0.3 from captcha.image import imagecaptcha import numpy as np import matplotlib.pyplot as plt from...
隨機生成驗證碼
coding utf 8 created on mon sep 16 01 21 02 2019 author administrator import random from captcha.image import imagecaptcha import numpy as np from pil...
隨機生成驗證碼
private static int r private static int g private static int b private static stringbuffer buffer public static final char chars public static random ...