我目前正在尝试通过调用checkDate()
在div标签之间插入日期,但我不认为它返回的是我想要的,即formatDate()
的返回。我目前在div标签之间什么也没回来,但是当我在控制台记录formatDate
函数时,我知道它被击中了,因为日志正在打印出来。
function formatDate(date) {
return "the date is" + date;
}
function checkDate(date) {
let newDate = date
return this.formatDate(newDate)
}
<div>{{ checkDate(date) }}</div>
答案 0 :(得分:0)
<html>
<head>
<script>
function formatDate(date) {
return "the date is" + date;
}
function checkDate(date) {
let newDate = date;
return formatDate(newDate)
}
</script>
</head>
<body>
<div>{{ <script type="text/javascript">document.write(checkDate(new Date()))</script> }}</div>
</body>
</html>
我的系统上的输出: {{日期为2019年3月20日星期三11:13:50 GMT + 0800(澳大利亚西部标准时间)}}
因此您的设置似乎正常。 IT必须是不输出checkDate返回值的外部环境。