Open msforest opened 7 years ago
移动设备会自动识别数字开启相应的功能,通过下面代码阻止设备自动识别
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
<meta name="format-detection" content="address=no" />
<meta name="format-detection" content="date=no" />
如果需要开启相应的功能,在link上加相应的代码如<a href="tel:8602188888888">+86 021 88888888</a>
复合事件是dom3级事件中新增的一类事件,用于处理IME(Input Method Editor,输入法编辑器)的输入序列,有compositionstart/compositionupdate/compositionend
三种,对于输入键盘上能找到的字符一般使用change事件,而对于像中文、拉丁文等物理键盘上找不到的字符,使用复合事件进行处理;而在chrome53之后和ios10.3以后把change事件
和复合事件
顺序做了调整,因此变更之后需要对事件进行手动处理,在compositionend
之后手动调用一次change事件。
// Opera 8.0+
const isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
const isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
const isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// 是否是IOS系统
const isIOS = navigator.userAgent.indexOf('iPhone') >= 0 || navigator.userAgent.indexOf('iPad');
// 获取IOS系统版本
const IOSVer = navigator.userAgent.match(/\d[\d]*_\d[_\d]*/i) && parseFloat(navigator.userAgent.match(/\d[\d]*_\d[_\d]*/i)[0].split('_').join('.'));
// Internet Explorer 6-11
const isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
const isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
const isChrome = !!window.chrome;
// Blink engine detection
const isBlink = (isChrome || isOpera) && !!window.CSS;
let isComposition = false;
element.addEventListener('compositionstart', function(e){
isComposition = true;
}, false};
element.addEventListener('compositionend', function(e){
isComposition = false;
if(isChrome || (isIOS && IOSVer >= 10.3) ){ // 判断浏览器是否是Chrome 或者 是否是IOS系统以及 IOS版本是否 大于等于10.3
dothing();
}
}, false};
element.addEventListener('change', function(e){
if(!isComposition ) {
dothing();
}
}, false};
解决方法:在点击弹窗的入口时设置页面高度为100%,消失的入口设置高度为auto
$scope.showMask = function{
angular.element('html,body').css({overflow:'hidden', height: '100%'});
}
$scope.hideMask = function(){
angular.element('html,body').css({overflow:'auto', height: 'auto'});
}
解决方法:在回到上一页时,使用$timeout()
重新设置样式
$timeout(function(){
angular.element('html,body').css({height: '100%'})
}, 0);
解决方法:对输入框进行复合事件监听(IME)
let lock = false;
angular.element('input').bind('compositionstart', function(e){
lock=true;
}).bind('compositionend', function(e){
lock=false;
}).bind('input', function(e){
if(lock) return ;
doanything();
});
解决方法:使用scrollIntoView()
方法(javascript高级程序设计第三版304页声明所有浏览器都已实现该方法)
$watch()
监听对象没有进行实时更新$scope.$watch('obj', function(newVal, oldVal){
...
}); //没有设置第三个参数
因为obj是scope里的一个对象,对对象进行监听的时候,需要加上第三个参数,表示使用angular.equals方法比较;如果是对基本类型监听,无需加入第三个参数;省略第三个参数有利于提示应用的性能。$watch参考
出现这种问题是因为在服务器返回的数据太多,转换后的字符串长度超过了2^28。为什么会有长度限制?个人认为是因为字符串是直接保存在内存中,而js可利用的内存大小是有限的。而express框架在传输对象的时候,会先使用JSON转换,此时数据还没到前端。
数组最大长度 既然字符串有长度限制,那数组呢,有没有最大长度? MDN给出了明确的答案:
当设置 Array.length 属性为负数或者长度大于等于2^32 时。
为什么 Array(数组) 和 ArrayBuffer(数组缓冲区) 的长度会受到限制?因为 Array 和 ArrayBuffer 的 length(长度) 属性被定义为一个32位无符号整形(unsigned 32-bit integer)的值,所以它只能存储 0 - 232-1 之间的数。超出也会报无效长度错误。
参考链接
webpack-dev-server热更新失效 sublime
,果然,有前人也遇到过这种情况,感谢前辈分享在Ubuntu中,使用Sublime修改文件,webpack-dev-server不自动编译热替换。
这里把webstorm失效的链接也贴一下webstorm修改文件,webpack-dev-server不会自动编译刷新解决办法
修改系统的fs.inotify.max_user_watches的值,可以使用下列两种办法来修改
方法一: 使用Shell命令直接修改
sudo sysctl fs.inotify.max_user_watches=524288
方法二: 修改sysctl.conf配置文件
sudo vim /etc/sysctl.conf
在文件的末尾加上
fs.inotify.max_user_watches=524288
重新从配置文件“/etc/sysctl.conf”加载内核参数设置
sudo sysctl -p /etc/sysctl.conf
我们可以通过下面的shell命令来查看Inotify监控文件的最大数量:
sysctl -a | grep inotify
ClientAliveInterval 60
#server每隔60秒发送一次请求给client,然后client响应,从而保持连接
ClientAliveCountMax 3
#server发出请求后,客户端没有响应得次数达到3,就自动断开连接,正常情况下,client不会不响应
ServerAliveInterval 60
#client每隔60秒发送一次请求给server,然后server响应,从而保持连接
ServerAliveCountMax 3
#client发出请求后,服务器端没有响应得次数达到3,就自动断开连接,正常情况下,server不会不响应
不修改配置文件
在命令参数里ssh -o ServerAliveInterval=60
这样子只会在需要的连接中保持持久连接, 毕竟不是所有连接都要保持持久的
移动端问题
桌面端问题
angular问题
javascript问题
css问题
webpack
linux