Failed to load resource: the server responded with a status of 404 (Not Found)的問題怎么解決呢
這是我的代碼,js文件和css樣式都是能用的,console.log里的內(nèi)容都能輸出,所以autoPlay函數(shù)是能夠運(yùn)行的,實(shí)在想不到是哪里的資源沒下下來。(而且上一個(gè)課程的走馬燈我也是能跑出來的)
```
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
? ? $(()=>{
? ? ? ? console.log('頁面元素加載完執(zhí)行');
? ? ? ? var outerWidth = 600,
? ? ? ? ? ? outerHeight = 400,
? ? ? ? ? ? speed = 3,
? ? ? ? ? ? transitionTime = .3,
? ? ? ? ? ? initIndex = 0,
? ? ? ? ? ? setTimeId = null;
? ? ? ? var $marquee=$('.marquee');
? ? ? ? var $content=$marquee.find('.content');
? ? ? ? var $list=$content.find('.list');
? ? ? ? var listLength = $list.length;//list的長度之和就是content的寬度
? ? ? ? var contentWidth = outerWidth*listLength;//outerWidth就是之前所設(shè)置的list的寬度
? ? ? ? var style = document.styleSheets;//獲得頁面加載的樣式表
? ? ? ? $marquee.css({
? ? ? ? ? ? "width":`${outerWidth}px`,
? ? ? ? ? ? "height":`${outerHeight}px`
? ? ? ? });
? ? ? ? $list.css({//content需要list來算
? ? ? ? ? ? "width":`${outerWidth}px`,
? ? ? ? ? ? "height":`${outerHeight}px`
? ? ? ? });
? ? ? ? $content.css({//content需要list來算
? ? ? ? ? ? "width":`${contentWidth}px`,
? ? ? ? ? ? "height":`${outerHeight}px`,
? ? ? ? });
? ? ? ? var clone = $list.eq(0).clone();//選擇list列表里的第一個(gè)元素把它克隆下來放到content里面
? ? ? ? $content.append(clone);
? ? ? ? function autoPlay(){
? ? ? ? ? ? console.log('函數(shù)開始');
? ? ? ? ? ? initIndex++;
? ? ? ? ? ? setTimeId = setInterval(()=>{
? ? ? ? ? ? ? ? $content.css({
? ? ? ? ? ? ? ? ? ? "transition":`transform ${transitionTime}s ease`,
? ? ? ? ? ? ? ? ? ? "transform":`tanslateX(-${initIndex*outerWidth}px)`
? ? ? ? ? ? ? ? })
? ? ? ? ? ? },speed*1000)
? ? ? ? ? ? console.log('函數(shù)末端');
? ? ? ? }
? ? ? ? autoPlay()
? ? })
</script>
```