'text / paperscript'未在webmatrix 3中识别

时间:2014-02-03 17:18:29

标签: javascript html5 webmatrix

我是javascript和html的新手,正在尝试使用paper.js创建一个基本网页。我还阅读了关于改进脚本加载时间的内容,并实现了我在网上找到的快速内联脚本加载器。我已经验证了加载器(使用弹出框)使其成为paper.js文件。但是,我尝试在下一行实例化一个paperscript脚本标记,webmatrix不会将其识别为有效的类型参数。无论如何,我尝试以类似的方式加载一个文件到装载机,它仍然没有运行文件。代码应该有助于更好地解释我正在尝试做的事情:

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title>  HTML Canvas  </title>
    </head>
     <body>

        <canvas id="mainCanvas" width="800" height="600">
            Canvas not supported.
        </canvas>

        <script type="text/javascript">
            function speedLoadJS(a,b){var c=document.createElement("script");c.type="text/javascript";if(c.readyState){c.onreadystatechange=function(){if(c.readyState=="loaded"||c.readyState=="complete"){c.onreadystatechange=null;b()}}}else{c.onload=function(){b()}}c.src=a;document.getElementsByTagName("head")[0].appendChild(c)}
            function speedLoadPS(a,b,t){var c=document.createElement("script");c.type="text/paperscript";c.canvas=t;if(c.readyState){c.onreadystatechange=function(){if(c.readyState=="loaded"||c.readyState=="complete"){c.onreadystatechange=null;b()}}}else{c.onload=function(){b()}}c.src=a;document.getElementsByTagName("head")[0].appendChild(c)}
        </script>

        <script type="text/javascript">speedLoadJS("public/paper-full.min.js", function(){})</script>
        <script type="text/javascript">speedLoadPS("public/testDraw.js", function(){}, "mainCanvas")</script>
    </body>
</html>

testDraw.js就是paper.js网站上的简单例子:

// Create a Paper.js Path to draw a line into it:
var path = new Path();
// Give the stroke a color
path.strokeColor = 'black';
var start = new Point(100, 100);
// Move to start and draw a line from there
path.moveTo(start);
// Note the plus operator on Point objects.
// PaperScript does that for us, and much more!
path.lineTo(start + [ 100, -50 ]);

1 个答案:

答案 0 :(得分:0)

IIS(和IIS Express)要求在applicationHost.config或web.config中注册每个mime类型。 text / paperscript mime类型未注册,因此无法提供。查看这篇文章,为LESS做同样的事情:

http://bob.yexley.net/using-less-css-with-visual-studio-and-iis-express/

关于类似主题的另一篇文章:

http://www.tomasmcguinness.com/2011/07/06/adding-support-for-svg-to-iis-express/

快乐的编码!