False Error: A constructor name should not start with a lowercase letter babel/new-cap

False Error: A constructor name should not start with a lowercase letter babel/new-cap

嗯,我有一个 Babel 误报错误。

这是控制台中的错误。

ERROR in ./src/app/playlist/playlist.js

/Users/macbook-lucas/refreex/src/app/playlist/playlist.js
  6:23  error  A constructor name should not start with a lowercase letter  babel/new-cap

✖ 1 problem (1 error, 0 warnings)

 @ ./src/app/playlist/index.js 12:16-37
 @ ./src/index.js

这是代码:

import {webtorrent} from 'webtorrent';

class PlaylistController {
  contructor() {
    this.TorrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4';
    this.Client = new webtorrent();
  }
}

export const playlist = {
  templateUrl: "app/playlist/playlist.html",
  controller: PlaylistController,
  bindings: {
    playlist: '<'
  }
};

就像rici说的:

我对 Babel 一无所知,但我的直觉告诉我表达式 new foo() 应该构造一个 class foo 的对象。因此,如果 class 名称必须以大写字母开头,则必须是 new Foo()。或 new Webtorrent(),在您的情况下(根据错误消息,请参阅第 6 行)。 –