layui selectM multi-select box click does not take effect

Problem: When using the extension of selectM, the multi-selection in the drop-down box does not take effect when clicking.

solve:

var tagIns;
layui.config({
     base: './'
}).extend({
     selectM: 'assets/libs/layui_extends/selectM', // 插件路径
}).use(['layer', 'form', 'jquery', 'selectM'], function () {
     $ = layui.jquery;
     var form = layui.form, selectM = layui.selectM;
     $.get('xxx', {
          token: getToken()
     }, function (res) {
          if (res.code == 0) {
              //多选标签-基本配置
              if(tagIns) tagIns.render(); // 重点!!!如果已存在,需要重载
              tagIns = selectM({
                  elem: '#selectedZyps',    //元素容器【必填】
                  data: res.data,   //候选数据【必填】
                  max: res.data.length,
                  tips: '请选择',
                  selected: selectZypsArr,
                  //verify: 'required',  //添加验证
                  field: {    //候选项数据的键名
                       idName: 'xxx',
                       titleName: 'aaa'
                  }
               });
          }
     })      
});

The road is long and long, I will search up and down!

Guess you like

Origin blog.csdn.net/weixin_38817361/article/details/129047681
Recommended