vant-weapp 弹窗dialog 使用以及按钮居中问题

2,526 阅读1分钟

引入:

  1. 在 app.json 或 index.json 中引入组件
"usingComponents": {
    "van-dialog" :  "path/to/vant-weapp/dist/dialog/index"
}
  1. 在xxx.wxml中写入

van-dialog id="van-dialog" />

  1. 在xxx.js中引入

import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';(此处写入你自己的路径)

使用:

    Dialog.alert({
      message: '请订阅最新计划',
      customStyle:"width:100%;"
    }).then(() => {
      // on close
     
    }); 

确定按钮不居中问题

image.png

修改 dialog 组件代码, 给原本的custom-style,替换成custom-style="color: {{ confirmButtonColor }};width:100%;",就是增加了一个width:100%.