我使用JSPM
创建了一个带有SPA的ASP.NET Core Razor Pages应用程序具有
default.html中
<!DOCTYPE html>
<html>
<head>
<title>JSPM</title>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<script src="packages/system.js"></script>
<script src="jspm.config.js"></script>
<script src="jspm.dev.js"></script>
<script >
System.import('xperiandri/app.ts');
</script>
<!--<script>
SystemJS.import('aurelia-bootstrapper');
</script>-->
</body>
</html>
jspm.config.js
SystemJS.config({
paths: {
"github:": "packages/github/",
"npm:": "packages/npm/"
},
browserConfig: {
"baseURL": "/",
"paths": {
"xperiandri/": "/"
}
},
nodeConfig: {
"paths": {
"xperiandri/": ""
}
},
transpiler: "plugin-typescript",
typescriptOptions: {
"module": "system",
"target": "es6",
"tsconfig": false,
"sourceMap": true
},
packages: {
"xperiandri": {
"main": "app.ts",
"defaultExtension": "ts",
"meta": {
"*.ts": {
"loader": "plugin-typescript"
}
}
}
}
});
app.ts
export class App {
constructor() {
console.log("JSPM initialized");
var textnode = document.createTextNode("Welcome JSPM!");
document.body.appendChild(textnode);
}
}
我希望看到添加了Welcome JSPM!
文字的标记,但这不会发生。
我做错了什么?
app.ts由Microsoft Edge下载,在开发人员工具中检入。然而,它的媒体类型是视频,而不是文本。
请求
Accept: application/x-es-module, */*
Accept-Encoding: gzip, deflate
Accept-Language: uk, ru; q=0.8, en-US; q=0.5, en; q=0.3
Connection: Keep-Alive
Host: localhost:41467
Referer: http://localhost:41467/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16275
响应
Accept-Ranges: bytes
Content-Type: video/vnd.dlna.mpeg-tts
Date: Sun, 27 Aug 2017 22:01:34 GMT
ETag: "1d31766378d8152:-1"
Last-Modified: Thu, 17 Aug 2017 14:36:31 GMT
Server: Kestrel
Transfer-Encoding: chunked
X-Powered-By: ASP.NET
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNc0JDQvdC00YDRltC5XERldlxYcGVyaUFuZHJpXEx5c292Lk1uZ1xzcmNcV2ViXGFwcC50cw==?=
答案 0 :(得分:1)
如果下载了文件,则意味着mime类型错误。
您需要为p1(p1a1,p1a2)
个文件ts
或text/x.typescript
尝试在启动配置中添加此内容
text/prs.typescript