項(xiàng)目問題
1.BEM命名
B:Block是塊泳炉,一個(gè)獨(dú)立的組件估脆,將所有東西都劃分成一個(gè)組件
E:Element是塊中的子節(jié)點(diǎn),為了表明子節(jié)點(diǎn)屬于哪個(gè)塊衰倦,寫法是 block__element(連接符:__)
M:Modifier聲明某個(gè)節(jié)點(diǎn)的修飾狀態(tài)(連接符:--)
2.【js】防止按鈕在短時(shí)間內(nèi)被多次點(diǎn)擊的方法
3.【js】移動(dòng)端css :active有效
document.body.addEventListener('touchstart', function () {});
4.【js】點(diǎn)擊除特定dom外的地方袒炉,遮罩消失
ui.$btnSeeDetail.on('click',function(e){
$('.chance-detail').fadeIn()
$(document).on('click',function(){
$('.chance-detail').fadeOut()
})
e.stopPropagation();
})
$('.chance-detail').on('click',function(e){
e.stopPropagation();
})
//舉例:
<form class="search-form">
<input type="text" class="search-form__username">
<input type="password" class="search-form__password">
<button id="J_Submit" class="search-form__submit--active"></button>
<form>
5.【兼容ie6】 select框 刺穿彈窗
原因:select脫離z軸到最高層
解決:在彈窗dom結(jié)構(gòu)前加iframe,遮住刺穿的select框
<iframe id="DivShim" scrolling="no" style="position:absolute;top:0;left:0;width:282px;height:128px;-moz-opacity:0;-webkit-opacity:0; opacity:0; filter:alpha(Opacity=0);background:transparent;">
</iframe>
/-- 年會(huì) --/
1.【html】移動(dòng)端輸入數(shù)字
<input type="number" pattern="[0-9]*" />
在安卓端設(shè)置input類型為number樊零,可限制鍵盤只輸入數(shù)字我磁,在ios端,要加入pattern驗(yàn)證輸入字段的模式驻襟,才能限制數(shù)字輸入夺艰。
2.【js】阻止冒泡,默認(rèn)行為
e.stopPropagetion()
e.preventDefault()
/--- 信鴿 --/
1..【js】去重
let arr = [1, 2, 2, 3];
let set = new Set(arr);
let newArr = Array.from(set); // Array.from方法可以將 Set 結(jié)構(gòu)轉(zhuǎn)為數(shù)組沉衣。
console.log(newArr); // [1, 2, 3]