小程序vant组件库Notify 消息通知的使用

一.在需要使用notify的.json文件内引入路径

 "usingComponents": {
  "van-notify": "../../dist/notify/index"
  }

二.在需要使用的页面的js中再次引入notify

import Notify from '../../dist/notify/notify';

然后在你想要提示的方法中使用它,我这里是在数据请求失败的时候给的提示

 Notify({
      message: '系统错误,请重试',
      duration: 1000,
      selector: '#custom-selector',
    });

三.在页面中添加相应的节点

<van-notify id="van-notify" />

猜你喜欢

转载自blog.csdn.net/YaoQing222/article/details/108316632