亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Vue:在 TypeScript 中使用“export * as”時模塊解析失敗

Vue:在 TypeScript 中使用“export * as”時模塊解析失敗

阿晨1998 2023-03-24 13:39:42
我有一個index.ts文件可以導出我所有的助手函數。為了以更方便的方式導入它們,我想使用export asTypeScript 3.8 的功能。所以這是我的代碼:// index.tsexport * from './logging';export * as TypeHelper from './types';export * as ValidationHelper from './validation';這是我在運行時遇到的錯誤npm run serve:ERROR  Failed to compile with 1 errors                                                                                                                                               13:44:55error  in ./src/services/helpers/index.tsModule parse failed: Unexpected token (2:9)File was processed with these loaders: * ./node_modules/cache-loader/dist/cjs.js * ./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader/index.js * ./node_modules/eslint-loader/index.jsYou may need an additional loader to handle the result of these loaders.| export * from './logging';> export * as TypeHelper from './types';| export * as ValidationHelper from './validation';|  @ ./src/plugins/router/index.ts 3:0-41 92:8-11 98:8-11 @ ./src/main.ts @ multi (webpack)-dev-server/client?http://192.168.179.4:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.tsType checking in progress...No type errors foundVersion: typescript 3.9.7我怎樣才能解決這個問題?
查看完整描述

1 回答

?
牧羊人nacy

TA貢獻1862條經驗 獲得超7個贊

根據 Mozilla 的說法,該語法不在當前規范中。那可能是 ES12


export * from …; // does not set the default export

export * as name1 from …; // Draft ECMAScript? 2O21

現在,您可以導入它們,然后再導出它們。


import * as TypeHelper from './types';

export TypeHelper;


查看完整回答
反對 回復 2023-03-24
  • 1 回答
  • 0 關注
  • 496 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號