[: currentTime | date:'mm:ss' :] [: timeLeft | date:'mm:ss' :]

示例参考 - ES6

<script>
  class Bike {
    go(dest) {
      console.log('正在前往' + dest);
    }
  }

  class User {
    constructor(balance) {
      this.balance = balance;
    }
  }

  class BikeManger {
    send(user, dest) {
      if (user.balance < 10)
        throw '余额不足';

      if (dest != '六六坡' && dest != '背背山')
        throw dest + '暂无存车点';

      let bike = new Bike();
      bike.go(dest);
    }
  }

  const whh = new User(11);
  const manger = new BikeManger();
  manger.send(whh, '双门洞');
</script>

示例参考 - ES6

<script>
  function Bike() {}

  Bike.prototype.go = function (dest) {
    console.log('正在前往' + dest);
  };

  function User(balance) {
    this.balance = balance;
  }

  function BikeManger() {}

  BikeManger.prototype.send = function (user, dest) {
    if (user.balance < 10)
      throw '余额不足';

    if (dest != '六六坡' && dest != '背背山')
      throw dest + '暂无存车点';

    var bike = new Bike();
    bike.go(dest);
  };

  var whh = new User(11);
  var manger = new BikeManger();
  manger.send(whh, '双门洞');
</script>
登录后评论