Paper.js external file will not load

前端 未结 3 1291
一生所求
一生所求 2021-01-18 17:23

I am just trying to get into paper.js. Code works fine when they\'re inlined. But when I move them to an external file and src it there, errors starts to pop up :( Can anyon

3条回答
  •  耶瑟儿~
    2021-01-18 18:04

    Unfortunately, you need to run this through a server to link the two files, either setting up an XAMPP server yourself or publishing your files to a hosted server so the http://... protocol can be used rather than file:/// (your case, because you are using a localhost).

    One way to do this and solve your problem is:

    1) navigate to your project folder in the terminal

    2) if you have python v2.x installed then run:

    python -m SimpleHTTPServer
    

    or for python v3.x:

    python -m http.server
    

    3) open up your browser and navigate to http://localhost:8000

    4) select and open your .html file

    It worked for me.

    More details in related topic: "Cross origin requests are only supported for HTTP." error when loading a local file

提交回复
热议问题