×
您的位置: 首页 > 编程笔记

今天使用bootstrap中的tagsinput控件,碰到个小问题

Bootstrap TagsInput 时间:2019-08-01  查看:1102   收藏

我直接使用时,后台一直报Uncaught Can't add objects when itemValue option is not set错误,

代码如下:

<div>
    <input id="uploadFiles" placeholder="请选择..." data-role="tagsinput" />
</div>

  

        $("#uploadFiles").tagsinput({
            itemValue: 'id',
            itemText: 'text',
        });        var test={id:'adfa',text:'fff'};
        
        $("#uploadFiles").tagsinput('add', test);

查了半天,没找到问题所在,后来在stackoverflow发现一个相同的错误的帖子:

http://stackoverflow.com/questions/31926025/bootstrap-tagsinput-cant-add-objects-when-itemvalue-option-is-not-set

原来是写了data-role="tagsinput"属性,去掉后就OK啦

 

0% (0)
0% (0)