【发布时间】:2016-09-27 20:29:47
【问题描述】:
代码:
<script>
var expectedFunc = () => showAllSteps();
function showAllSteps() {
alert('showAllSteps');
expectedFunc = () => nextStep();
}
function nextStep() {
alert('nextStep');
expectedFunc = () => showAllSteps();
}
function toggleFunction() {
expectedFunc();
}
</script>
<button type="button" class="btn" name="showAllBtn" onclick="toggleFunction()">Show all</button>
在这段代码中,expectedFunc = () => showAllSteps();=()=> 在 IE 中不起作用。有谁知道 IE 中这个切换的替代品是什么?
【问题讨论】:
-
expectedFunc = showAllSteps;- 你只是定义一个函数,它只是调用一个函数;您也可以重新分配原始功能。
标签: javascript internet-explorer browser cross-browser