TypeScript exports is not defined

后端 未结 6 1659
攒了一身酷
攒了一身酷 2020-12-13 08:45

I\'m trying to use export and import but it not working I get an error

Here is my code HTML :




    <         


        
6条回答
  •  北海茫月
    2020-12-13 09:03

    TypeScript by default uses node module resolution. Node.js / CommonJS uses exports keyword. However, CommonJS doesn't run in browser without a module loader or module bundler. Hence, you need browserify or webpack to get it running in browser.

    Check out this link https://www.typescriptlang.org/docs/handbook/gulp.html

    You can also set module setting to none in compiler options section in tsconfig.json:

    { "compilerOptions": { "target": "es5", "module": "none" } }

提交回复
热议问题