1. 问题描述

WebStorm 中,使用 yarn install 命令编译 uniapp 项目。

编译过程中各种报错(示例如下:),但是都靠安装各种环境解决了。

npm ERR! path E:\XXX\node_modules\node-sass

gyp info using node-gyp@9.1.0
gyp info using node@16.19.0 | win32 | x64
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration

gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details

然后,最难受的来了...

启动小程序后,uni-popup 相关组件自动弹出,且点击后无响应,提示方法未定义等,其实是组件引入错误

this.$refs.popup.open is not a function

TypeError: Cannot read property 'open' of null

2. 解决方案

重点:

  1. 使用 HBuilder X 编译,而不是 nodeJs

  2. 为项目安装 uni-ui 组件库

HBuilderX内置相关环境,开箱即用,无需配置nodejs;且为uni-app做了特别强化

详见 uniapp官网介绍

3. 站内关联

WebStorm 运行 uni-app