聊一下我今天Vue打包时遇到的一个错误

npm run test

> vue3-admin@0.1.0 test C:\Users\Administrator\Desktop\project\blinds_pos_admin
> vue-cli-service build --mode test

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating

|  Building for test...

 ERROR  Failed to compile with 1 error

 error  in ./src/views/goods/price-set-list-f/index.vue?vue&type=script&lang=js&

Module parse failed: Unexpected token (871:51)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/babel-loader/lib/index.js
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|       storeEndPickerOptions: {
|         disabledDate(time) {
>           let date = new Date(data.storeDialogData?.startStr).getTime();
|           return time.getTime() < date - 86400000;
|         }

 @ ./src/views/goods/price-set-list-f/index.vue?vue&type=script&lang=js& 1:0-298 1:314-317 1:319-614 1:319-614
 @ ./src/views/goods/price-set-list-f/index.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./src/main.js

 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue3-admin@0.1.0 test: `vue-cli-service build --mode test`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the vue3-admin@0.1.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2021-11-30T01_45_39_456Z-debug.log

百思不得其解

打包生产环境没有问题,很奇怪,打包测试的时候提示我要安装一个插件!然后我把我对象中的storeDialogData?.startStr 中的问号去掉就好了。

或者把a?.b改成a&&a.b,他们是等价的。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐