小程序中使用第三方npm包

1、在小程序的根目录中创建执行:npm init

2、在依赖中写入相关的依赖包

"dependencies": {
    "vant-weapp": "^0.5.16",
    "echarts": "^4.1.0",
  }

3、工具—构建npm

4、在index.json或app.json中引入组件

{
  "usingComponents": {
    "titleArea": "/components/titleArea/titleArea",
    "van-button": "/miniprogram_npm/vant-weapp/button/index"
  },
  "navigationStyle": "custom"
}

5、使用组件

测试

你可能感兴趣的:(小程序)