Typescript 无法引导angular2-cosole上没有错误
我使用gulp将ts传输到js,我的ts文件与其他静态资源一起正确地生成在dist文件夹中Typescript 无法引导angular2-cosole上没有错误,typescript,gulp,angular,transpiler,Typescript,Gulp,Angular,Transpiler,我使用gulp将ts传输到js,我的ts文件与其他静态资源一起正确地生成在dist文件夹中 //tsconfig.js { "compilerOptions": { "outFile": "scripts.js", //this can be commented to retain the original file structure instead of concatenating into one file "target": "es
//tsconfig.js
{
"compilerOptions": {
"outFile": "scripts.js", //this can be commented to retain the original file structure instead of concatenating into one file
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"gulpfile.js",
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
我使用systemjs导入scripts.js
//index.html
<!DOCTYPE html>
<html>
<head>
<base href="/">
<meta charset="UTF-8">
<title>ZEFR</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,700,600,700italic,400italic,600italic,800,800italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<my-app>Loading</my-app>
</body>
<script src="lib/es6-shim.js"></script>
<script src="lib/angular2-polyfills.js"></script>
<script src="lib/system.src.js"></script>
<script src="lib/Rx.js"></script>
<script src="lib/angular2.dev.js"></script>
<script src="lib/router.dev.js"></script>
<script>
System.config({
packages: {
dist: {
format: 'register',
defaultExtention: 'js'
}
}
});
System.import('scripts.js')
.then(null, console.error.bind(console))
</script>
</html>
这将有助于您:
System.import('dist/scripts')
.then(null, console.error.bind(console))
您的
scripts.js
位于dist中,而您的索引位于父目录中。您不需要在那里添加--.js
。这将帮助您:
System.import('dist/scripts')
.then(null, console.error.bind(console))
您的
scripts.js
位于dist中,而您的索引位于父目录中。您不需要在那里添加-.js。我已经尝试过在传输时维护相同的文件夹结构。dist包含相应ts文件的js文件。还是不走运。相同的加载。。。。screenI尝试在传输时保持相同的文件夹结构。dist包含相应ts文件的js文件。还是不走运。相同的加载。。。。是的,我试过了,对我来说很有意义。但是这在angular2-pollyfills.js中给了我一个错误,因为“加载http:localhost:3000/dist/scripts.jstry时出错。请尝试将system.js放在索引中的polyfills之上。htmlist:{format:'register',defaultextension:'js'}这是“dist”吗“这个问题。对于我来说,dist是使用expressor为所有静态文件提供服务的文件夹。在使用SystemJs时,不应将所有文件合并到一个文件中。那是你的错误。是的,我试过了,对我来说是有意义的。但是这在angular2-pollyfills.js中给了我一个错误,因为“加载http:localhost:3000/dist/scripts.jstry时出错。请尝试将system.js放在索引中的polyfills之上。htmlist:{format:'register',defaultextension:'js'}这是“dist”吗“这个问题。对于我来说,dist是使用expressor为所有静态文件提供服务的文件夹。在使用SystemJs时,不应将所有文件合并到一个文件中。那是你的错误。