我在超级(道具); 上收到错误调用目标不包含任何签名。
有人请解释错误的含义以及解决方法吗? TY
declare var require: any
var React = require('react');
var ReactDOM = require('react-dom');
class Button extends React.Component {
constructor(props) {
super(props);
this.state = { count: 0 };
}
render() {
return (
<button> CLICK ME </button>
);
}
}
ReactDOM.render(<Button />, document.getElementById('root'));
答案 0 :(得分:0)
替换这段代码:
declare var require: any
var React = require('react');
var ReactDOM = require('react-dom');
... with:
import * as React from "react";
import * as ReactDOM from "react-dom";
您的全部新代码现在将如下所示:
// declare var require: any
// var React = require('react');
// var ReactDOM = require('react-dom');
import * as React from "react";
import * as ReactDOM from "react-dom";
class Button extends React.Component {
constructor(props) {
super(props);
this.state = { count: 0 };
}
render() {
return (
<button> CLICK ME </button>
);
}
}
ReactDOM.render(<Button />, document.getElementById('root'));