中文乱码的根源在于 windows 基于一些历史原因无法全面支持 utf-8 编码格式,并且也无法通过有效手段令其全面支持。
- 安装
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Document</title> | |
| <style> | |
| .ani_dot { |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| /** | |
| * Created by Li on 2017/3/26. | |
| */ | |
| function swap(array, i, j) { | |
| let temp | |
| temp = array[i] | |
| array[i] = array[j] | |
| array[j] = temp | |
| return array | |
| } |
| git push origin --delete <branchName> |
| function commafy(num){ | |
| return num && num | |
| .toString()//匹配一个数字,条件是后面跟着三个数字一次或多次,且末尾"." | |
| .replace(/(\d)(?=(\d{3})+\.)/g, function($1, $2){ | |
| console.log($1,$2) | |
| return $1 + ','; | |
| }); | |
| } | |
| console.log(commafy(1234355645.1343)) |
| function Promise(fn) { | |
| var state = 'pending', | |
| value = null, | |
| callbacks = [] | |
| this.then = function(onFulfilled) { | |
| return new Promise(function(resolve) { | |
| //handle方法是当前 promise 的内部方法 | |
| handle({ | |
| onFulfilled: onFulfilled || null, //上一个promise的回调 |
| .selector{ | |
| overflow: hidden; | |
| text-overflow:ellipsis; | |
| white-space: nowrap;/*不换行*/ | |
| width: 50%; | |
| } |
localStorage理论上来说是永久有效的,即不主动清空的话就不会消失,即使保存的数据超出了浏览器所规定的大小,也不会把旧数据清空而只会报错。
但需要注意的是,在移动设备上的浏览器或各Native App用到的WebView里,localStorage都是不可靠的,可能会因为各种原因(比如说退出App、网络切换、内存不足等原因)被清空。sessionStorage的生存期顾名思义,类似于session,只要关闭浏览器(也包括浏览器的标签页),就会被清空。由于sessionStorage的生存期太短, 因此应用场景很有限,但从另一方面来看,不容易出现异常情况,比较可靠。 | {"lastUpload":"2017-07-17T09:31:16.435Z","extensionVersion":"v2.8.2"} |