????$('.images>img:nth-child(1)').addClass('current')
????$('.images>img:nth-child(2)').addClass('wait')
????$('.images>img:nth-child(3)').addClass('wait')
上述不行
setTimeout(()?=>?{
????$('.images>img:nth-child(1)').addClass('current')
????$('.images>img:nth-child(2)').addClass('wait')
????$('.images>img:nth-child(3)').addClass('wait')
},?20)? ?可以箫攀。。。涉馁。汪疮。峭火。。什么智障啊智嚷。卖丸。
后續(xù):解決了,在html文件把script標簽放body最下面盏道。稍浆。。好吧。衅枫。
由window.scrollY=0引發(fā)的血案嫁艇。。弦撩。步咪。
在我的頁面留言板部分刷新頁面,顯示window.scrollY=0正常應(yīng)該是1000多益楼。猾漫。思考后認為問題出在從leancloud引入的數(shù)據(jù)庫沒有放head標簽,導(dǎo)致瀏覽器沒有在生成時算那些留言的像素(太扯淡了感凤,但一實驗好像真是)
在head標簽中放入
????<!--?留言板?下面兩行必須放這里悯周,不然scrollX為0,猜測從外部數(shù)據(jù)庫拿數(shù)據(jù)必須放head標簽?-->
????<script?src="http://cdn1.lncld.net/static/js/3.5.0/av-min.js"></script>
????<script?src="./js/data-import.js"></script>
果然問題解決陪竿。禽翼。但又帶來新的問題,由于這個script文件在head里面萨惑,結(jié)果拿不到DOM元素了捐康,這是正常的,因為還沒有生成嘛庸蔼。解总。但是很奇怪,見注釋
AV.init({
????appId:?"sGEeXThjIGNgADzjmPEkH8ap-gzGzoHsz",
????appKey:?"3G7BY7LcR8WuAkKktzehAcrN",
});
var?test?=?document.querySelector('section.message')? ?//這里拿不到
console.log('aa',?test)
var?query?=?new?AV.Query('Message');
query.find().then((messages)?=>?{
????console.log(messages)
????var?test?=?document.querySelector('section.message')? ? //這里居然能拿到姐仅?花枫??掏膏?
????console.log('aa',?test)
....}
更離奇的是劳翰,在這個queryfind外面,再寫一個?var?test?=?document.querySelector('section.message')??
????console.log('aa',?test)
居然先于在它上面的代碼執(zhí)行馒疹?佳簸??猜測:可能是query.find()在頁面全部生成后才執(zhí)行
好吧颖变,應(yīng)該去看源碼可能生均。。腥刹。