将输入字符串转换为整数

时间:2020-10-31 09:11:54

标签: string integer

对于以下代码,当我运行它并输入浮点数作为capacity_engine输入时,我收到一条错误消息:msg:int base 10的无效文字。

Rule can only have one resource source (provided resource and test + include + exclude) in {
  "use": [
    {
      "loader": "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\babel-loader\\lib\\index.js",
      "options": {
        "configFile": false,
        "babelrc": false,
        "cacheDirectory": true,
        "envName": "server",
        "presets": [
          [
            "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\@nuxt\\babel-preset-app\\src\\index.js",
            {
              "corejs": {
                "version": 3
              }
            }
          ]
        ]
      },
      "ident": "clonedRuleSet-30[0].rules[0].use[0]"
    }
  ]
}

  "use": [
  {
  "loader": "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\babel-loader\\lib\\index.js",
  "options": {
  "configFile": false,
  "babelrc": false,
  "cacheDirectory": true,
  "envName": "server",
  "presets": [
  [
  "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\@nuxt\\babel-preset-app\\src\\index.js",
  {
  "corejs": {
  "version": 3
  }
  }
  ]
  ]
  },
  "ident": "clonedRuleSet-30[0].rules[0].use[0]"
  }
  ]
  }
  at checkResourceSource (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:167:11)
  at Function.normalizeRule (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:198:4)
  at node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:110:20
  at Array.map (<anonymous>)
  at Function.normalizeRules (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:109:17)
  at new RuleSet (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:104:24)
  at new NormalModuleFactory (node_modules\@nuxt\webpack\node_modules\webpack\lib\NormalModuleFactory.js:115:18)
  at Compiler.createNormalModuleFactory (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:636:31)
  at Compiler.newCompilationParams (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:653:30)
  at Compiler.compile (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:661:23)
  at node_modules\@nuxt\webpack\node_modules\webpack\lib\Watching.js:77:18
  at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:22:1)
  at AsyncSeriesHook.lazyCompileHook (node_modules\tapable\lib\Hook.js:154:20)
  at Watching._go (node_modules\@nuxt\webpack\node_modules\webpack\lib\Watching.js:41:32)
  at node_modules\@nuxt\webpack\node_modules\webpack\lib\Watching.js:33:9
  at Compiler.readRecords (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:529:11)

1 个答案:

答案 0 :(得分:0)

您已经回答了自己的问题。您正在输入浮点数,但尝试在第2行将其转换为int。

该修补程序应该将第2行的int(...)更改为float(...)。