gpt4 book ai didi

javascript - "Object object"在 Javascript 中不再可用

转载 作者:行者123 更新时间:2023-11-28 19:55:57 26 4
gpt4 key购买 nike

我得到的输出看起来像这样

“对象对象不再可用,已从分配#257中删除”

使用以下代码

if(typeof find_staff.staff != 'undefined') {
var staff = find_staff.staff;
staff = $.extend({}, staff.preferences, staff.staff);

if(typeof(staff[staff_id]) != 'undefined') {
loop_continue = true;
}
else {
$('#' + i).html('<p>' + staff + ' is no longer available and has been removed from assignment #' + booking_id + '</p>');

// Break from loop
loop_continue = false;
}
}
else {
$('#' + i).html('<p>' + staff + ' is no longer available and has been removed from #' + v.booking_id + '</p>');

// Break from loop
loop_continue = false;
}

最佳答案

很明显 staff是一个对象,因为这就是 $.extend 返回的内容

var staff = find_staff.staff;
staff = $.extend({}, staff.preferences, staff.staff);

恰好一个对象的字符串表示是 [Object, object] .
这样做'<p>' + staff + ' is no lo...将对象与字符串连接起来,有效地执行 staff.toString()这给你 [Object, object]

关于javascript - "Object object"在 Javascript 中不再可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22559877/

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