1、页面导入样式时,使用link和@import有什么区别
1.link是HTML标签,@import是css提供的。
2.link引入的样式页面加载时同时加载,@import引入的样式需等页面加载完成后再加载。
3.link没有兼容性问题,@import不兼容ie5以下。
4.link可以通过js操作DOM动态引入样式表改变样式,而@import不可以。
2、将下划线改成驼峰命名
var str = 'a_cb';
str = str.replace(/(\w)(_)(\w)/g, function(word, $1, $2, $3){
console.log(word, $1, $2, $3)
return `${$1}${$3.toUpperCase()}`
});
// 简写
// str = str.replace(/(\w)(_)(\w)/g, (match, $1, $2, $3) => `${$1}${$3.toUpperCase()}`);
3、 写一个把字符串大小写切换的方法
var str = 'aVdfsVSDG'
str = str.replace(/([a-z]*)([A-Z]*)/g, (match, $1, $2) => `${$1.toUpperCase()}${$2.toLowerCase()}`)
4、 写一个判断数据类型的方法
Object.prototype.toString.call(v).replace(/^.{8}(.+)]$/,(m,$1)=> $1.toLowerCase())