【问题标题】:Unexpected character '#'意外字符“#”
【发布时间】:2020-01-09 15:30:21
【问题描述】:

我在使用 webpack 加载依赖项时运行 npm run dev 命令时收到此错误:

Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:\www\playing-with-texture-projection-in-three-js\src\lib\WebGLApp.js: Unexpected character '#' ;

                       export default class WebGLApp {
                           #updateListeners = []
                           #tmpTarget = new THREE.Vector3()
                           #rafID
                           #lastTime

                           constructor({
                              background = '#000',
                              backgroundAlpha = 1,
                              fov = 45,
                              near = 0.01,
                              far = 100,
                              ...options
                              } = {}) {
                              this.rend
                           .......
                           .......

我缺少什么(我使用的是普通的 javascript 和一些库)?

【问题讨论】:

标签: javascript npm webpack ecmascript-next


【解决方案1】:

正如@PatrickHund 在 cmets 中指出的那样,它是 EcmaScript 中的一项新功能。

您必须使用babel-plugin-transform-class-properties 插件来转换它们。

来源:https://sitepoint.com/javascript-private-class-fields

【讨论】:

    猜你喜欢
    • 2017-06-13
    • 1970-01-01
    • 2012-03-30
    • 2014-09-08
    • 2012-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多