const reg = {
// 验证固话
TEL: /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/,
// 验证手机号
MOBILE: /^1[3|4|5|7|8][0-9]\d{4,8}$/,
// 验证邮箱
EMAIL: /^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$/,
npm install npm@latest -g(可以更新npm至最新版本)
npm install webpack@latest -S 升级vue的版本
npm install vue-template-compiler@latest -S 升级compiler的版本
直接打开异步请求到的链接会被浏览器拦截。
可以使用如下解决方案:
async applyForAuth(row) {
const win = window.open('about:blank', '_blank');
const r = await getAuth(row.shopId);
if (r.code === '8001') {
win.location.href = r.data;
}
(function(){
const t = window.performance && performance.timing;
if (!t) {
return;
}
const loadTime = (t.loadEventEnd - t.navigationStart) / 1000;
alert(`This page loaded in ${loadTime} seconds`);
}())
function countString(str) {
const arr = str.split('');
let n = 1;
let result = '';
for (let i = 0; i < arr.length; i++) {
if (arr[i + 1] === arr[i]) {
n++;
}
else {
// 1
function cloneObject(obj, parent) {
if (typeof obj !== 'object') {
return null;
}
const o = obj instanceof Array ? [] : {};
for (let key in obj) {
function minNumbers() {
let len = Math.floor(Math.random() * 10 + 3);
let digit = Math.random().toString().slice(len);
console.log('给出的数字:', digit)
let arr = digit.split('');
let sort = arr.sort(function (a, b) {
return a - b;
});
最近前端圈闹的沸沸扬扬的快排算法,由于对算法不熟悉,先借鉴高程作者的方案在这里。
function swap(items, firstIndex, secondIndex) {
var temp = items[firstIndex];
items[firstIndex] = items[secondIndex];
items[secondIndex] = temp;
}
function partition(items, left, right) {
if (!("a" in window)) {
var a = 1;
}
console.log(a); // undefined
变量提升,在代码顶部申明
var a = undefined
,"a" in window
会返回true,if语句不会执行。
console.log(1);
new Promise(function (resolve, reject){
reject(true);
window.setTimeout(function (){
resolve(false);
}, 0);
}).then(function(){
console.log(2);
}, function(){
OlderNewer