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() { | |
| 'use strict'; | |
| // Your code here... | |
| let html = ` <div id="app"> | |
| <div class="uid-box"> | |
| <label for="uid">UID</label> | |
| <input type="text" id="_uid"> | |
| <button id="add-uid-btn">添加uid</button> | |
| <h4 id="uid-info" class="info"></h4> |
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
| // 加密字符串 | |
| const compileStr = function(code) { | |
| var c = String.fromCharCode(code.charCodeAt(0) + code.length); | |
| for (var i = 1; i < code.length; i++) { | |
| c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1)); | |
| } | |
| return escape(c); | |
| } | |
| // 解密字符串 | |
| const uncompileStr = function(code) { |
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 downloadIamge(imgsrc, type, name) { //下载图片地址和图片名 | |
| let image = new Image(); | |
| // 解决跨域 Canvas 污染问题 | |
| image.setAttribute("crossOrigin", "anonymous"); | |
| image.onload = function () { | |
| let canvas = document.createElement("canvas"); | |
| canvas.width = image.width; | |
| canvas.height = image.height; | |
| let context = canvas.getContext("2d"); | |
| context.drawImage(image, 0, 0, image.width, image.height); |
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
| // 安装 | |
| npm install body-parser -S | |
| // 使用 | |
| const bodyParser = require("body-parser"); | |
| // 'application/json' json格式 | |
| app.use(bodyParser.json()); | |
| // 'application/x-www-form-urlencoded' 序列化格式 |
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 randomTime(delay) { | |
| return Math.floor(Math.random() * delay) + 1; | |
| } | |
| function debounce(fun, delay) { | |
| var timer = null; | |
| return function () { | |
| var that = this, | |
| args = 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
| function deepCopy(obj) { | |
| // 处理null情况 | |
| if (!obj) { | |
| return newobj = obj; | |
| } | |
| let newobj = obj.constructor === Array ? [] : {}; | |
| if (typeof obj !== 'object') { | |
| newobj = obj; | |
| } else { | |
| for (let i in obj) { |
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
| //说明:因http缓存机制,访问相应网址也无法查看,因此需要点击左下角按钮并在地址栏回车(刷新无效),另外,控制台有对应地址。 | |
| (function () { | |
| 'use strict'; | |
| const params_review = '?kan=com-blocker1-review'; | |
| const params_interview = '?kan=com-blocker1-interview'; | |
| const url = window.location.href; | |
| var str = ''; | |
| if (url.includes ('review') && !url.includes (params_review)) { | |
| str = url.slice (0, url.indexOf ('?')) + params_review; | |
| console.log (str); |
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 React, {Component} from 'react'; | |
| const asyncComponent = (importComponent) => { | |
| return class extends Component { | |
| state = { | |
| component: null | |
| } | |
| componentDidMount() { | |
| importComponent() //我们传进来的函数返回我们想要的组件B |
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
| // 根据名字获取url参数 | |
| function getQueryByName(url, name) { | |
| var reg = new RegExp('[?&]' + name + '=([^&#]+)'); | |
| var query = url.match(reg); | |
| return query ? query[1] : null; | |
| } | |
| // 获取url参数数组 | |
| function parseQuery(url) { | |
| var queryObj = {}; |
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
| export default function () { | |
| function remChange() { | |
| var deviceWidth = document.documentElement.clientWidth; | |
| if (deviceWidth > 750) { | |
| deviceWidth = 7.5 * 100; | |
| } | |
| document.documentElement.style.fontSize = deviceWidth / 7.5 + 'px'; | |
| } | |
| remChange(); |