• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

想测试一下老师讲的ball.html的动画效果,但是不知道怎么弄?(我是win10系

如下是我的代码
        Promise animation                        .ball{                        width: 40px;                        height: 40px;                        border-radius: 20px;                }                .ball1{                        background: red;                }                .ball2{                        background: yellow;                }                .ball3{                        background: green;                }       


        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(marginLeftnode ball.jsServer 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. (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("404 Not Found

");                }        });}).listen(8080, "127.0.0.1");console.log("Server running at http://127.0.0.1:8080/");

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与1

你的代码里有几个小错误。。
分别在,31行 ,35行,46行,59行。
<blockquote>



  Promise animation
  
    .ball{
      width: 40px;
      height: 40px;
      border-radius: 20px;
    }
    .ball1{
      background: red;
    }
    .ball2{
      background: yellow;
    }
    .ball3{
      background: green;
    }
  









<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

使用道具 举报

发新帖

发布任务需求已有1031167位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!