zoukankan      html  css  js  c++  java
  • 微信小程序用vant,dialog弹出框

    官网如下:
    https://youzan.github.io/vant-weapp/#/dialog

    看效果

    1、json中引入

    "usingComponents": {
        "van-dialog": "/miniprogram_npm/@vant/weapp/dialog/index"
      }
    

    2、js引入

    import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
    

    3、wxml引入

    <van-dialog id="van-dialog" />
    
    
    <van-dialog id="wan-not-pass"
      use-slot
      title="请填写原因"
      show="{{ showDialog }}"
      show-cancel-button
      show-confirm-button
      confirm-button-text="确定"
      bind:close="onClose"
    >
    

    4、默认调用

    handleDelayPass() {
        console.log('通过');
        let _this = this;
        let {id} = _this.data;
        
        Dialog.confirm({
          title: '提示',
          message: '确认通过延迟申请审核吗?',
        })
          .then(() => {
            // on confirm
            httpRequest('/StreetManagerAssign/checkDelayApply', {
              id: id
            }, ({
              data
            }) => {
              // 页面刷新
              wx.showToast({
                icon: 'success',
                title: '操作成功',
                duration: 2000,
                success: function(){
                  setTimeout(function(){
                    // 页面刷新
                    _this.onShow()
                  }, 2000)
                }
              })
            }, err => {}, '')
          })
          .catch(() => {
            // on cancel
          });
        
      }
    

    5、自定义调用

    handleDelayNotPass() {
        console.log('不通过');
        this.setData({
          showDialog:true,
          delay_check_result:""
        });
    
      },
      onClose(e) {
        console.log(e);
        let _this = this;
        if (e.detail == 'confirm') {
          console.log('确认不通过');
          let {id,delay_check_result} = _this.data;
          if (!delay_check_result) {
            wx.showToast({
              title: '请填写原因',
              icon: 'none',
            })
          } else {
            httpRequest('/StreetManagerAssign/checkDelayApply', {
              id: id,
              type: 2,
              delay_check_result:delay_check_result
            }, ({
              data
            }) => {
              // 页面刷新
              wx.showToast({
                icon: 'success',
                title: '操作成功',
                duration: 2000,
                success: function(){
                  setTimeout(function(){
                    // 页面刷新
                    _this.onShow()
                  }, 2000)
                }
              })
            }, err => {}, '')
          }
        }
        
      },
      // 改变审核不通过原因
      onChangeContent(e){
        this.setData({  delay_check_result:e.detail.value})
      }
    

    小结:基本满足各种需求,可以灵活运用组件模式来自用处理弹出层的业务。

  • 相关阅读:
    jenkins 简单实现php集成上线部署
    关于PHP7
    关于版本迭代的那些事
    confirmit中手机端不能直接给input设置disabled属性
    confirmit中Html Styles有一处bug(或者说是一个坑)
    vsCode快捷键大全
    vscode打不开文件夹或文件夹未响应
    js中排序方法sort() 和 reverse()
    js最简单的编写地点
    js对象转换为json格式时,js对象属性中有值为null和undefined注意事项
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/15720596.html
Copyright © 2011-2022 走看看