0

我正在尝试添加标签输入。我的代码如下

if($('#tags_tagsinput').length == 0) {
        $('#tags').tagsInput({
            autocomplete_url: App.routes.social.tags.search(bootstrapFacility.id).fullRoute(),
            width: '100%',
            height: '35px',
            placeholderColor : '#666666',
            defaultText: '',
            caseInsensitiveUnique: true
        });
        $('#tags').importTags($('#tags').val());
    } else {
        $('#tags').importTags($('#tags').val());
    }

此代码工作正常,但随机抛出错误。页面将继续加载,控制台上将显示以下错误:

Uncaught TypeError: Cannot read property 'split' of undefined
at Function.t.fn.tagsInput.importTags (social_vendor.js:1)
at f.fn.init.t.fn.importTags (social_vendor.js:1)
at HTMLDocument.eval (eval at globalEval (social_vendor.js:1), <anonymous>:45:15)
at u (social_vendor.js:1)
at Object.add [as done] (social_vendor.js:1)
at f.fn.init.f.fn.ready (social_vendor.js:1)
at new f.fn.init (social_vendor.js:1)
at f (social_vendor.js:1)
at eval (eval at globalEval (social_vendor.js:1), <anonymous>:1:1)
at eval (<anonymous>)

我已经尝试调试相同的输入。它工作正常,但在随机时间它得到空字符串并抛出未定义。

4

0 回答 0