我在for循环中遇到问题,说它是重复的局部变量?我仍在尝试了解这一点,并已尽我所能调查并自行寻找答案,所以现在我向大家提问。如果您不介意,我想解释一下为什么它不起作用?
int x = 3;
String name = "Dirk";
x = x * 17;
System.out.print("x is " + x);
double d = Math.random();
while (x > 12) {
x = x - 1;
}
for (int x = 0; x < 10; x = x + 1) {
System.out.print("x is now " + x);
}
if (x == 10) {
System.out.print("x must be 10");
} else {
System.out.print("x isn't 10");
}
if ((x < 3) & (name.equals("Dirk"))) {
System.out.println("Gently");
}
答案 0 :(得分:1)
只需在module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
rules: [
{
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', ["es2015", { "modules": false }], 'stage-1']
}
},
{
test: /\.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS
]
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.scss']
},
devServer: {
historyApiFallback: true,
contentBase: './',
host: 'localhost',
port: 8080
}
};
循环中删除x
的第二个声明和重新分配:
for
否则,您可以简化以下说明:
for ( ; x < 10; x++) {
System.out.print("x is now " + x);
}
而不是x++
x = x + 1
而不是x*=19