聊一下我今天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

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐