当我运行时,npm run build我收到此错误:
ERROR in ./src/client.js 7:2\nModule parse failed: Unexpected token (7:2)\nFile was processed with these loaders:\n * ./node_modules/jshint-loader/index.js\nYou may need an additional loader to handle the result of these loaders.\n| \n| const component = (\n> <Router history={browserHistory}>\n| {routes}\n| </Router>\n @ multi babel-polyfill ./src/client.js main[1]\nRun Code Online (Sandbox Code Playgroud)\n\n./src/client.js(带有警告browserHistory-- 无法解析符号 \'browserHistory\' )
import React from \'react\';\nimport ReactDOM from \'react-dom\';\nimport { browserHistory, Router } from \'react-router\';\nimport routes from \'./routes\';\n\nconst component = (\n <Router history={browserHistory}>\n {routes}\n </Router>\n);\n\nReactDOM.render(component, …Run Code Online (Sandbox Code Playgroud) 我有很多城市都有这样的物体:
[{id: 1, name: 'New York'}, {id: 2, name: 'London'} ...]
Run Code Online (Sandbox Code Playgroud)
我的值是id。
我将数组中的元素(名称)放入选择列表。但我需要添加第一个选项,其中包含数组(名称)中的值,该选项具有相应的 id,但我无法使其工作。
我的组件:
const propTypes = {
cities: PropTypes.array,
enteredEvent: PropTypes.array
};
class newEvent extends Component {
constructor(props) {
super(props);
this.state = {
showInOption: ''
};
this.handleDictionary = this.handleDictionary.bind(this);
this.searchTypeEvent = this.searchTypeEvent.bind(this);
}
componentDidMount() {
this.searchTypeEvent();
}
handleDictionary(e) {
...
}
searchTypeEvent() {
if (this.props.enteredEvent.cityid !== null && this.props.enteredEvent.cityid !== undefined) { // if I have id value
const type = this.props.cities.find(el => el.id …Run Code Online (Sandbox Code Playgroud) 当我运行时eslint .出现错误:
Error: .eslintrc.js \xc2\xbb eslint-config-standard-with-typescript:\n Configuration for rule "@typescript-eslint/restrict-plus-operands" is invalid:\n Value {"skipCompoundAssignments":false} should NOT have additional properties.\nRun Code Online (Sandbox Code Playgroud)\n我在配置中禁用了“@typescript-eslint/restrict-plus-operands”规则:
\nrules: {\n ...\n '@typescript-eslint/restrict-plus-operands': 'off',\n}\nRun Code Online (Sandbox Code Playgroud)\n但它不起作用,我得到同样的错误。
\n有什么问题?
\n软件包版本:
\n"@typescript-eslint/eslint-plugin": "^5.62.0",\n"@typescript-eslint/parser": "^6.4.1",\n"eslint": "^8.48.0",\n"eslint-config-prettier": "^9.0.0",\n"eslint-config-standard-with-typescript": "^39.0.0",\n"eslint-plugin-import": "^2.28.1",\n"eslint-plugin-n": "^16.0.2",\n"eslint-plugin-prettier": "^5.0.0",\n"eslint-plugin-promise": "^6.1.1",\n"typescript": "^5.2.2",\nRun Code Online (Sandbox Code Playgroud)\n节点 v14.18.2
\nnpm v6.14.15
\nUPD
\n将“@typescript-eslint/eslint-plugin”更新到6.4.1版本后,出现了新的错误:
\n/node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager/dist/referencer/ClassVisitor.js:123\n withMethodDecorators ||=\n ^^^\nSyntaxError: Unexpected token '||='\nRun Code Online (Sandbox Code Playgroud)\n 我需要添加对象列表,但我无法理解如何正确地做到这一点.我从控制台获得的每个新对象.怎么解决?
我的尝试:
namespace ExampleCars
{
public class Car
{
public string name;
public int speed;
public Car(string name, int speed)
{
this.name = name;
this.speed = speed;
}
}
class Program
{
static void Main(string[] args)
{
string name;
int speed, elements;
List<Object> cars = new List<Object>();
elements = Convert.ToInt32(Console.ReadLine());
if (elements > 0)
{
for (int i = 0; i < n; i++)
{
name = Convert.ToString(Console.ReadLine());
speed = Convert.ToInt32(Console.ReadLine());
Car newCar = new Car(name, speed);
cars.Add(newCar);
}
} …Run Code Online (Sandbox Code Playgroud) reactjs ×2
.net ×1
c# ×1
class ×1
eslint ×1
javascript ×1
node-modules ×1
node.js ×1
npm ×1
oop ×1
react-router ×1
typescript ×1
webpack ×1