我正在使用jQuery 3.1.0,我想使用该console.log()函数调试我的代码(我在Firefox 47.0中使用默认的开发人员控制台).
我尝试了以下代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
console.log($("body").height());
alert($("body").height());
});
</script>
Run Code Online (Sandbox Code Playgroud)
(<script>元素在<body>元素中(最后,就在前面)</body>.
尝试运行页面时,我收到正确号码的警报,但控制台为空.当我尝试输入console.log('foo');命令行时,它会响应undefined:
(对不起我糟糕的英语,我很抱歉.)
编辑:我现在尝试使用以下代码,但它仍然似乎不起作用:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
console.log('hi');
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我使用Flow作为我的 JavaScript 代码的静态类型检查器,但出现以下错误:
Cannot call this.props.onChange because undefined [1] is not a function.
[1] 25? onChange?: Time => any,
:
192? if (isValid && this.props.onChange) {
193? const match = this.matchValue(value);
194? if (match) {
195? this.props.onChange(this.parsedToTime(this.parseValue(match)));
196? }
197? }
198? }
Run Code Online (Sandbox Code Playgroud)
我对 Props 的定义是这样的(定义了更多的 props,用 标记...):
type Props = {
...
onChange?: Time => any,
...
};
Run Code Online (Sandbox Code Playgroud)
然后我在 React 类定义中使用 props 作为类型参数:
export default class TimeInput extends React.Component<Props, State> {
...
// ...and in …Run Code Online (Sandbox Code Playgroud)