This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <timer-btn @click.native="sendCode()" class="btn btn-default" :disabled="disabled" @run="sendCode" ref="btn" | |
| :second="60"></timer-btn> | |
| </template> | |
| <script> | |
| // 登录验证的按钮组件 | |
| Vue.component('timerBtn', { | |
| template: `<button type="button" :disabled="disabled || time > 0 " style="white-space: nowrap;font-size: 13px;">{{text}}</button>`, | |
| // 初始化时间 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import CryptoJS from 'crypto-js'; | |
| export class CryptoAES { | |
| constructor(word, secretKey, params) { | |
| this.secretKey = this.parseEncode(secretKey); | |
| this.params = this.params || { | |
| mode: CryptoJS.enc.ECB, | |
| padding: CryptoJS.enc.Pkcs7 | |
| } | |
| this.word = this.parseEncode(word); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| margin: 0; | |
| padding: 0; | |
| background: rgb(230,230,230); | |
| color: rgb(50,50,50); | |
| font-family: 'Open Sans', sans-serif; | |
| font-size: 112.5%; | |
| line-height: 1.6em; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "math" | |
| ) | |
| func circleArea(radius float64) (float64, error) { | |
| if radius < 0 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| func main() { | |
| /* | |
| 数组的排序 | |
| 让数组中的元素具有一定的顺序。 | |
| arr := [5]int{15,23,8,10,7} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 返回f()的带有记忆功能的版本 | |
| // 只有当f()的实参的字符串表示都不相同时它才会工作 | |
| // 记忆的本质是:牺牲算法的空间复杂度以换取更优的时间复杂度,在客户端JavaScript中代码的执行时间复杂度往往成为瓶颈,因此在大多数场景下,这种牺牲空间换取时间的做法以提升程序执行效率的做法是非常可取的 | |
| function memorize(f) { | |
| var cache = {}; // 将值保存在闭包内 | |
| return function() { | |
| // 将实参转换为字符串形式,并将其用作缓存的键 | |
| var key = arguments.length + Array.prototype.join.call(arguments, ","); | |
| if (key in cache) return cache[key]; | |
| else return cache[key] = f.apply(this, arguments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 基本数据类型: | |
| undefined 转换之后仍是 undefined(类型也是 undefined) | |
| boolean 值转换之后是字符串 "false"/"true" | |
| number 类型(除了 NaN 和 Infinity)转换之后是字符串类型的数值 | |
| symbol 转换之后是 undefined | |
| null 转换之后是字符串 "null" | |
| string 转换之后仍是string | |
| NaN 和 Infinity 转换之后是字符串 "null" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.assign2 = function(target, ...source) { | |
| if (target == null) { | |
| throw new TypeError('Cannot convert undefined or null to object') | |
| } | |
| let ret = Object(target) | |
| source.forEach(function(obj) { | |
| if (obj != null) { | |
| for (let key in obj) { | |
| if (obj.hasOwnProperty(key)) { | |
| ret[key] = obj[key] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.create2 = function(proto, propertyObject = undefined) { | |
| if (typeof proto !== 'object' && typeof proto !== 'function') { | |
| throw new TypeError('Object prototype may only be an Object or null.') | |
| if (propertyObject == null) { | |
| new TypeError('Cannot convert undefined or null to object') | |
| } | |
| function F() {} | |
| F.prototype = proto | |
| const obj = new F() | |
| if (propertyObject != undefined) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function instanceof(left, right) { | |
| let proto = left.__proto__ | |
| while (true) { | |
| if (proto === null) return false | |
| if (proto === right.prototype) { | |
| return true | |
| } | |
| proto = proto.__proto__ | |
| } | |
| } |
NewerOlder