微信小程序安装weui

  1. 在项目根目录下执行:
npm init
  1. 然后下包
npm install --save weui-miniprogram

然后报了这么一段错

npm ERR! code ERR_TLS_CERT_ALTNAME_INVALID
npm ERR! errno ERR_TLS_CERT_ALTNAME_INVALID
npm ERR! request to https://registry.cnpmjs.org/weui-miniprogram failed, reason: Hostname/IP does not match certificate’s altnames: Host: registry.cnpmjs.org. is not in the cert’s altnames: DNS:r.cnpmjs.org
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2021-03-04T15_43_20_662Z-debug.log

关闭npm的https(取消npm的https认证),执行:

npm config set strict-ssl false

再次下载包,成功!

  1. 构建npm模块
    工具——构建npm
  2. 使用npm
    详情——本地设置——使用npm模块
  3. 引入weui样式
    根目录下的app.wxss文件中引入
@import './miniprogram_npm/weui-miniprogram/weui-wxss/dist/style/weui.wxss';
  1. 使用,这里拿官网的例子
    在页面的json文件中配置字段
{
  "usingComponents": {
    "mp-dialog": "weui-miniprogram/dialog/dialog"
  }
}

在对应的wxml文件中使用

<mp-dialog title="test" show="{{true}}" bindbuttontap="tapDialogButton" buttons="{{[{text: '取消'}, {text: '确认'}]}}">
    <view>test content</view>
</mp-dialog>

参考文档
request to https://registry.cnpmjs.org/vue failed, reason: Hostname/IP does not match certificate‘s
快速上手 | 微信开放文档

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值