1

我是新手但由于某种原因,它不会加载 css 或图像。我把它们都放在同一个目录中:

  • 网络根:
    • 索引.html
    • 样式.css
    • 图片.jpg

代码只是:

<link rel='stylesheet' href="styles.css">
<img src='/pic.jpg' align="left" width="150" height="150">

但是,无论我尝试什么,它们都不会加载。那么有人可以回答我吗?

4

1 回答 1

0

首先,确保您已经正确设置了静态路由:

"routes":[
    ["method":"get", "uri":"/**",  
     "handler":PerfectHTTPServer.HTTPHandler.staticFiles,
     "documentRoot":"./webroot"]
]

然后尝试“快速构建”并在终端中运行应用程序

如果使用 Xcode,请从 Xcode“运行”中选择“编辑方案”,并将“工作目录”选项设置为“$(PROJECT_DIR)”。

于 2017-09-19T17:02:10.580 回答