小编Dav*_*d C的帖子

unknown property 'optimization'

I'll trying to use uglify with webpack but got this error:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'optimization'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
Run Code Online (Sandbox Code Playgroud)

I have

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
Run Code Online (Sandbox Code Playgroud)

and

optimization: {
        minimizer: [new …
Run Code Online (Sandbox Code Playgroud)

uglifyjs webpack

4
推荐指数
1
解决办法
2798
查看次数

在javascript中创建对象时如何保存动态键引用?

有没有办法在对象启动期间实现这一点?

//uuid() returns a new uuid
let Obj = {
  [uuid()]:{
    id: (get the ID that was just created)
  }
}
Run Code Online (Sandbox Code Playgroud)

所以输出应该是这样的

Obj {
  5cb93583: {
  id: 5cb93583
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript

3
推荐指数
1
解决办法
87
查看次数

如何使switch语句更有效?

我有以下代码

//var r, t, y, f, g, h, c, v, b
    switch(event.key) {
        case 'r' : input.execute("game_stats_build " + r);
        break;
        case 't': input.execute("game_stats_build " + t);
        break;
        case 'y': input.execute("game_stats_build " + y);
        break;
        case 'f': input.execute("game_stats_build " + f);
        break;
        case 'g': input.execute("game_stats_build " + g);
        break;
        case 'h': input.execute("game_stats_build " + h);
        break;
        case 'v': input.execute("game_stats_build " + v);
        break;
        case 'b': input.execute("game_stats_build " + b);
        break;
      }
Run Code Online (Sandbox Code Playgroud)

这是多余的,每次我做出改变,我都要做很多打字.我怎么能写得更好?

javascript

2
推荐指数
1
解决办法
67
查看次数

ReactJS 动态添加 onClick 事件

我有一个反应功能组件,我想动态决定是否要在其上使用 onClick 处理程序,如下所示:

const foo () => {
  let add_onClick = true;
  return (
    <div *(if add_onClick ==true then add an onClick event)*/>
  )
}
Run Code Online (Sandbox Code Playgroud)

我想我可以将组件转换为一个类,为组件创建一个 Ref 然后在 componentDidMount 中添加一个 click eventListener,但是有没有更简单的方法来做到这一点?

reactjs

1
推荐指数
1
解决办法
4898
查看次数

标签 统计

javascript ×2

reactjs ×1

uglifyjs ×1

webpack ×1