1. 发布后缓存问题(仅针对h5)
enableExtract: true,
output: {
filename: 'js/[name].[hash:8].js',
chunkFilename: 'js/[name].[chunkhash:8].js'
},
miniCssExtractPluginOption: {
filename: 'css/[name].[hash:8].css',
chunkFilename: 'css/[id].[chunkhash:8].css'
}

参考官方文档:https://nervjs.github.io/taro/docs/config-detail.html#h5minicssextractpluginoption
2. 全局变量配置
npm install --save-dev cross-env

参考官方文档: https://nervjs.github.io/taro/docs/config-detail.html#defineconstants
3. h5 添加vConsole
<script src="https://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/3.0.0/vconsole.min.js" type="text/javascript"></script>
<script type="text/javascript">
new VConsole();
</script>
4. 版本切换升级
1. 更新cli
npm install -g @tarojs/cli@[版本号] 或 $ taro update self [version] 或 yarn global add @tarojs/cli@[version]
2. 更新项目中 Taro 相关的依赖
$ taro update project [version]
如命令更新失败,需要在 package.json 文件手动更新依赖版本,然后重新安装依赖。
这里有详细说明
https://taro-docs.jd.com/taro/docs/GETTING-STARTED.html#%E6%9B%B4%E6%96%B0
5. 编译错误:
报错:Module build failed (from ./node_modules/@tarojs/webpack-runner/node_modules/babel-loader/lib/index.js),如下图:

解决方案:
node版本问题,如果同时进行的项目必须用不同的node版本,那就下载个nvm
详情参考下://www.greatytc.com/p/87466f802fea
6. 线上环境去掉vConsole
npm install babel-plugin-transform-remove-console --save-dev
let plugins = [
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread',
['transform-runtime', {
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": 'babel-runtime'
}]
];
if (process.env.ENVIRONMENT === 'product') {
plugins.push('transform-remove-console');
}
7. npm run dev 报错:getaddrinfo ENOTFOUND localhost和解决方法
https://segmentfault.com/a/1190000015274463?utm_source=tag-newest
