1
我正在使用TypeScript编写脚本,当我使用browserify进行转换时,我的主变量未在浏览器中找到。浏览器中找不到Browserify全局变量
main.ts
import { GameSmart } from './GameSmart';
const gamesmart = new GameSmart();
gulpfile.js
/* require's snipped */
gulp.task('build', function() {
return browserify()
.add('./src/gamesmart/main.ts')
.plugin(tsify)
.bundle()
.on('error', function (error) {
console.error(error);
throw error;
})
.pipe(source('gamesmart.js'))
.pipe(gulp.dest('build/'));
});
在我的网页,我包括新创建的文件,并试图调用gamesmart
变量,但它是未找到。
<script scr="/path/to/sdk.js">
<script>
gamesmart.game.started();
</script>
如何将它作为全局/根变量?