gpt4 book ai didi

javascript - 类型错误 : fun is not a function

转载 作者:行者123 更新时间:2023-11-28 06:12:07 24 4
gpt4 key购买 nike

当我调用OpenModelWindow函数时显示错误fun不是函数这是我的函数代码

function OpenModelWindow(url, option) {

var fun;
try {
if (parent != null && parent.$ != null && parent.$.ShowIfrmDailog != undefined) {
fun = parent.$.ShowIfrmDailog
}
else {
fun = $.ShowIfrmDailog;
}
}
catch (e) {
fun = $.ShowIfrmDailog;
}
fun(url, option);
}

最佳答案

那是因为有趣(如果可能未定义)。要解决这个问题,请检查 fun 的类型:

function OpenModelWindow(url, option) {

var fun;
try {
if (parent != null && parent.$ != null && parent.$.ShowIfrmDailog != undefined) {
fun = parent.$.ShowIfrmDailog
}
else {
fun = $.ShowIfrmDailog;
}
}
catch (e) {
fun = $.ShowIfrmDailog;
}
if (typeof fun == 'function') // <----
fun(url, option);
}

关于javascript - 类型错误 : fun is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36284133/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com