Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解释为脚本但使用MIME类型应用程序/dart传输的资源_Dart_Mime Types_Dart Io - Fatal编程技术网

解释为脚本但使用MIME类型应用程序/dart传输的资源

解释为脚本但使用MIME类型应用程序/dart传输的资源,dart,mime-types,dart-io,Dart,Mime Types,Dart Io,我正在通过HttpServer发送Dart文件,但每当我收到它时,Chrome就会说: "Resource interpreted as Script but transferred with MIME type application/dart: "http://localhost:8000/dart/game.dart"." 客户的线路是: 给出文件的行是: ifnew RegExp/dart/*.hasMatchuri{ 新的Filestatic/+uri.substring1.exis

我正在通过HttpServer发送Dart文件,但每当我收到它时,Chrome就会说:

"Resource interpreted as Script but transferred with MIME type application/dart: "http://localhost:8000/dart/game.dart"."
客户的线路是:

给出文件的行是:

ifnew RegExp/dart/*.hasMatchuri{ 新的Filestatic/+uri.substring1.exists.thenbool exists{ 如果!存在,返回; 新的Filestatic/+uri.substring1.readAsString.thenString内容{ ifuri.substringuri.length-2,uri.length==js request.response.headers.contentType=新ContentTypeapplication,javascript,字符集:utf-8; 其他的 request.response.headers.contentType=新ContentTypeapplication,dart; request.response.writecontents; 请求、响应、关闭; }; }; } 当我直接转到URL时,它会给出我的文件;谷歌Chrome网络说:

远程地址:127.0.0.1:8000 请求URL:http://localhost:8000/dart/game.dart 请求方法:获取 状态代码:200 OK 请求HeaderView源 接受:*/* 接受编码:gzip、deflate、sdch 接受语言:en-US,en;q=0.8 缓存控制:最大年龄=0 连接:保持活力 主机:localhost:8000 推荐人:http://localhost:8000/play 用户代理:Mozilla/5.0 Windows NT 6.1;WOW64 AppleWebKit/537.36 KHTML,如Gecko Chrome/39.0.2171.71 Safari/537.36 响应头视图源 内容类型:应用程序/dart 传输编码:分块 x-content-type-options:nosniff x-frame-options:SAMEORIGIN x-xss-protection:1;模式=块
我能做什么?

一切都很好。你可以忽略它。如果在本机不支持Dart的浏览器中运行脚本,Dart将自动注入一个脚本,该脚本将用.js版本替换.Dart版本!这要求您使用默认的发布生成工具。否则你必须确定。这条消息只是说您使用了一个application/dart mime类型的.dart文件作为默认的JS文件。这段代码的目的是什么?目前,直接提供Dart源代码是没有意义的。如果出于开发目的需要此调用,则应将该调用转发给pub-service实例,并让它处理其余的调用。Dart初始化代码负责浏览器请求适当的源代码,而pub serve则负责其余的工作。