【问题标题】:Placeholder when using minimum length使用最小长度时的占位符
【发布时间】:2022-11-11 08:38:31
【问题描述】:

我正在使用 shouldLoad 功能在从远程源加载数据之前设置最小字符长度,例如示例here

shouldLoad:function(query){
        if ( query.length < 3 ) return false;
  return true;
},

有没有办法向用户显示他们必须输入这个最少字符数,就像 select2 一样?

谢谢

【问题讨论】:

    标签: tom-select


    【解决方案1】:

    当然,

    你可以在你的渲染器函数中使用not_loading,当你从shouldLoad返回false时触发。

    例子:

    render: {       
                option: function(item, escape) {
                    return `<div>${ escape(item.name) }</div>`;
                },
                item: function(item, escape) {
                    return `<div>${ escape(item.name) }</div>`;
                },
                not_loading:function(data,escape){
                    return `<div>Please enter 2 or more characters </div>`;
                },
            },
        });
    

    您可以从他们的官方doc 了解更多信息。

    希望能帮助到你。

    【讨论】:

      猜你喜欢
      • 2012-05-08
      • 1970-01-01
      • 2021-06-17
      • 1970-01-01
      • 2022-01-24
      • 2018-01-25
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多