function Login() { this.captchaUrl = "/captcha" this.userName = "" this.password = "" this.captcha = "" } Login.prototype.RefreshCaptcha = function () { let self = this; $("#captcha-img").click(function () { let timestamp = new Date().getTime(); self.captchaUrl = "/captcha" + "?t=" + timestamp $("#captcha-img").attr('src', self.captchaUrl); //显示图片 }) } Login.prototype.run = function () { this.RefreshCaptcha() } // 构造执行入口 $(function () { feather.replace() // 模板过滤方法 // if (window.template) { // template.defaults.imports.domainSubstring = function (dateValue) { // if (dateValue.length > 40 ) { // return dateValue.substring(0, 37) + "..." // } else { // return dateValue // } // } // } let login = new Login() login.run() })