第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

想測試一下老師講的ball.html的動畫效果,但是不知道怎么弄?(我是win10系統(tǒng))求解答

想測試一下老師講的ball.html的動畫效果,但是不知道怎么弄?(我是win10系統(tǒng))求解答

星辰Iron 2016-09-17 17:25:21
如下是我的代碼<!DOCTYPE?html> <html> <head> <title>Promise?animation</title> <style?type="text/css"> .ball{ width:?40px; height:?40px; border-radius:?20px; } .ball1{ background:?red; } .ball2{ background:?yellow; } .ball3{ background:?green; } </style> </head> <body> <div?class="ball?ball1"?style="margin-left:0"></div> <div?class="ball?ball2"?style="margin-left:0"></div> <div?class="ball?ball2"?style="margin-left:0"></div> <script?type="text/javascript"> </script> var?ball1?=?document.querySelector('.ball1') var?ball2?=?document.querySelector('.ball2') var?ball3?=?document.querySelector('.ball3') function?animate(ball,distance,cb){ setTimeout(function(){ var?marginLeft?=?parseInt(ball.style.marginLeft,10) if(marginLeft?===?distance){ cb?&&?cb() } else{ if(marginLeft<distance){ marginLeft++ } else{ marginLeft-- } ball.style.marginLeft?=?marginLeft animate(ball,distance,cb) } },13) } animate(ball1,100,function(){ animate(ball2,200,function(){ animate(ball3,300,function()) }) }) </body> </html>我是node ball.js命令啟動服務(wù)器的,訪問地址是:http://localhost:8080/,但是訪問之后總是出現(xiàn)如下錯誤D:\imooc\promise>node?ball.js Server?running?at?http://127.0.0.1:8080/ D:\imooc\promise\ball.js:15 ????????path.exists(pathname,function(exists){ ?????????????^ TypeError:?path.exists?is?not?a?function ????at?Server.<anonymous>?(D:\imooc\promise\ball.js:15:7) ????at?emitTwo?(events.js:87:13) ????at?Server.emit?(events.js:172:7) ????at?HTTPParser.parserOnIncoming?[as?onIncoming]?(_http_server.js:533:12) ????at?HTTPParser.parserOnHeadersComplete?(_http_common.js:103:23)ball.js 的源碼如下var?http?=?require('http') var?url??=?require('url') var?path?=?require('path') var?fs???=?require('fs') http.createServer(function?(req,?res)?{ var?pathname=__dirname+url.parse(req.url).pathname; if?(path.extname(pathname)=="")?{ pathname+="/"; } if?(pathname.charAt(pathname.length-1)=="/"){ pathname+="index.html"; } path.exists(pathname,function(exists){ if(exists){ switch(path.extname(pathname)){ case?".html": res.writeHead(200,?{"Content-Type":?"text/html"}); break; case?".js": res.writeHead(200,?{"Content-Type":?"text/javascript"}); break; case?".css": res.writeHead(200,?{"Content-Type":?"text/css"}); break; case?".gif": res.writeHead(200,?{"Content-Type":?"image/gif"}); break; case?".jpg": res.writeHead(200,?{"Content-Type":?"image/jpeg"}); break; case?".png": res.writeHead(200,?{"Content-Type":?"image/png"}); break; default: res.writeHead(200,?{"Content-Type":?"application/octet-stream"}); } fs.readFile(pathname,function?(err,data){ res.end(data); }); }?else?{ res.writeHead(404,?{"Content-Type":?"text/html"}); res.end("<h1>404?Not?Found</h1>"); } }); }).listen(8080,?"127.0.0.1"); console.log("Server?running?at?http://127.0.0.1:8080/");
查看完整描述

1 回答

已采納
?
OlderSkee

TA貢獻123條經(jīng)驗 獲得超103個贊

你的代碼里有幾個小錯誤。。

分別在,31行 ,35行,46行,59行。

<!DOCTYPE html>
<html>
<head>
? ?<title>Promise animation</title>
? ?<style type="text/css">
? ? ? ?.ball{
? ? ? ? ? ?width: 40px;
? ? ? ? ? ?height: 40px;
? ? ? ? ? ?border-radius: 20px;
? ? ? ?}
? ? ? ?.ball1{
? ? ? ? ? ?background: red;
? ? ? ?}
? ? ? ?.ball2{
? ? ? ? ? ?background: yellow;
? ? ? ?}
? ? ? ?.ball3{
? ? ? ? ? ?background: green;
? ? ? ?}
? ?</style>
</head>
<body>
<div class="ball ball1" style="margin-left:0"></div>
<div class="ball ball2" style="margin-left:0"></div>
<div class="ball ball2" style="margin-left:0"></div>

<script type="text/javascript">

? ?var ball1 = document.querySelector('.ball1')
? ?var ball2 = document.querySelector('.ball2')
? ?var ball3 = document.querySelector('.ball3')

function animate(ball,distance,cb){
setTimeout(function(){
var marginLeft = parseInt(ball.style.marginLeft,10)

if(marginLeft === distance){
cb && cb()
}
else{
if(marginLeft<distance){
marginLeft++
}
else{

marginLeft--
}

ball.style.marginLeft = marginLeft+"px";
animate(ball,distance,cb)
}
},13)

}

animate(ball1,100,function(){
? ?animate(ball2,200,function(){
? ? ? ?animate(ball3,300,function(){
? ?})
})
})

</script>


</body>
</html>

對照下你自己的。再復(fù)制過去試試

查看完整回答
反對 回復(fù) 2016-09-17
  • 星辰Iron
    星辰Iron
    我把那幾個小錯誤修改了,然后啟動的是ball.js這個文件,但是總是會提示如下錯誤,麻煩幫我瞧瞧有啥問題沒 D:\imooc\promise\ball.js:15 path.exists(pathname,function(exists){ TypeError: path.exists is not a function at Server.<anonymous> (D:\imooc\promise\ball.js:15:7) at emitTwo (events.js:87:13) at Server.emit (events.js:172:7) at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:533:12) at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
  • OlderSkee
    OlderSkee
    path.exists(pathname,function(exists)報錯不是一個函數(shù), 可能是你node的版本原因,exists方法已經(jīng)不存在于path模塊了,改去fs了 改成 fs.exists(pathname,function(exists)試試看
  • 星辰Iron
    星辰Iron
    還是說不是一個函數(shù)
點擊展開后面1
  • 1 回答
  • 0 關(guān)注
  • 1766 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號