1. 發(fā)布后緩存問題(僅針對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 相關(guān)的依賴
$ 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
詳情參考下:http://www.reibang.com/p/87466f802fea
6. 線上環(huán)境去掉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