npm支持:小程序基础库版本2.2.1或以上,及开发工具1.0.1808300或以上开始,小程序支持使用npm安装第三方包
1、安装npm包
① 打开小程序的终端
npm i +包名

②此时会在package.json里面看到

③ 点击详情 --> 本地设置 --> 勾选”使用npm模块“
点击开发者工具中的菜单栏: 工具 --> 构建 npm


2、使用npm包
① js中引入npm包

② 使用npm
const myPackage = require('@weidandan01/demo')
const packageOther = require('@weidandan01/demo/add')
网友评论