Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery中的javascript错误:string.replace(rmsPrefix,“ms-”javascript错误_Javascript_Jquery_Runtime Error - Fatal编程技术网

jquery中的javascript错误:string.replace(rmsPrefix,“ms-”javascript错误

jquery中的javascript错误:string.replace(rmsPrefix,“ms-”javascript错误,javascript,jquery,runtime-error,Javascript,Jquery,Runtime Error,我在本地看到了这个错误。当我附加某个特定DOM时会发生这种情况: TypeError: string is undefined return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); jquery.js (line 622) 它并没有出现在生产上,但它经常发生在我当地。我调试过了,但什么也找不到。Im使用jQuery1.8.2 在这里发布关于它的信息,希望其他人已经发现了这一点。(我不指望

我在本地看到了这个错误。当我附加某个特定DOM时会发生这种情况:

TypeError: string is undefined  

return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );

jquery.js (line 622)
它并没有出现在生产上,但它经常发生在我当地。我调试过了,但什么也找不到。Im使用jQuery1.8.2

在这里发布关于它的信息,希望其他人已经发现了这一点。(我不指望有解决办法)

以下是导致该问题的代码:

flash = function(type, message, secondaryMessage) {
    var flash_location = $('.flash-location');
    var secondary = '';
    type = type || 'error';
    message = message || (type == 'success' ? 'Success' : 'Error');
    if(secondaryMessage){
        secondary = '<p class="secondary">'+secondaryMessage+'</p>';
    }
    var top = 5;
    flash_location.append($('<div class="flash"><div class="flash-content ' + type + '" style="top:'+top+'px;"><table><tr><td class="flash-icon"></td><td><p class="primary">' + message + '</p>'+secondary+'</td></tr></table></div></div>').fadeIn('normal'));
};
flash=功能(类型、消息、第二消息){
var flash_location=$('.flash location');
var次要=“”;
类型=类型| |“错误”;
message=message | |(type='success'?'success':'Error');
如果(第二条消息){
secondary='

'+secondaryMessage+'

'; } var-top=5; flash_location.append($('

'+message+'

'+secondary+'').fadeIn('normal'); };
如果使用DOM构建
append
元素,是否仍会出现问题

flash = function(type, message, secondaryMessage) {
    var flash_location = $('.flash-location'),
        top = 5,
        table = $('<table />'),
        tr = $('<tr />'),
        td = $('<td />'),
        p = $('<p />'),
        div = $('<div />'),
        td1 = td.clone().addClass('flash-icon'),
        td2 = td.clone().append(p.clone().addClass('primary')),
        flashContent = div.clone().addClass('flash-content').addClass(type).css('top', top + 'px'),
        flash = div.clone().addClass('flash');
    type = type || 'error';
    message = message || (type == 'success' ? 'Success' : 'Error');
    if(secondaryMessage){
        td2.append(p.clone().addClass('secondary').text(secondaryMessage));
    }
    tr.append(td1).append(td2);
    table.append(tr);
    flashContent.append(table);
    flash.append(flashContent);
    flash_location.append(flash).fadeIn('normal'));
};
flash=功能(类型、消息、第二消息){
变量flash_location=$(“.flash location”),
top=5,
表=$(''),
tr=$(''),
td=$(''),
p=$(“

”), div=$(''), td1=td.clone().addClass('flash-icon'), td2=td.clone().append(p.clone().addClass('primary'), flashContent=div.clone().addClass('flash-content').addClass(type).css('top',top+'px'), flash=div.clone().addClass('flash'); 类型=类型| |“错误”; message=message | |(type='success'?'success':'Error'); 如果(第二条消息){ 追加(p.clone().addClass('secondary').text(secondaryMessage)); } tr.append(td1)、append(td2); 表3.追加(tr); flashContent.append(表); flash.append(flashContent); flash_location.append(flash.fadeIn('normal')); };


我们怎么知道?(假设我们不是读心术的人)也许更大的范围会有所帮助…我认为字符串是保留字或变量字符串未定义。在返回字符串之前,请在使用此
replace()
的位置显示代码,并尝试通过console.log(字符串)。它不也是未定义的吗?据我所知,调用此函数(
$.camelCase
)并传递
未定义的
的唯一位置是
.css
。您是否正在以某种方式调用
$(“…”).css(未定义“…”)