uniapp阻止Modal模态框关闭

要阻止uniapp的Modal模态框关闭,没有找到相关api,但可以通过保存配置立即打开的方式变相实现阻止关闭:

      const option = {
        title: "输入礼品券名称",
        content: '节日礼品券',
        placeholderText: '礼品券名称(小于5个字符)',
        editable: true,
        confirmText: "确定",
        success: (res) => {
          const err = '名称不能为空,且小于5个字符';
          if(!res.content || res.content.length > 5) {
            option.content = res.content;
            uni.showToast({ title: err, icon: 'none', complete:() => uni.showModal(option) });
            return;
          }
          // TO DO DO...
        }
      }

      uni.showModal(option);

 

posted @ 2024-11-25 16:32  我的五年  阅读(468)  评论(0)    收藏  举报