引入:
- 在 app.json 或 index.json 中引入组件
"usingComponents": {
"van-dialog" : "path/to/vant-weapp/dist/dialog/index"
}
- 在xxx.wxml中写入
van-dialog id="van-dialog" />
- 在xxx.js中引入
import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';(此处写入你自己的路径)
使用:
Dialog.alert({
message: '请订阅最新计划',
customStyle:"width:100%;"
}).then(() => {
// on close
});
确定按钮不居中问题
修改 dialog 组件代码, 给原本的custom-style,替换成custom-style="color: {{ confirmButtonColor }};width:100%;",就是增加了一个width:100%.