使用 serve-favicon (v2.3.2)/ 节点 (v7.4.0)/ 表达 (v4.14.0)与 Typescript (v2.1.5)和ES6,我试图获得一个favicon通常:
在我的 server.ts
中import * as favicon from "serve-favicon";
...
export class Server {
public app: express.Application;
public static bootstrap(): Server {...}
constructor() {...}
public config() {
this.app.use(express.static(path.join(__dirname, "public")));
...
this.app.use(favicon(path.join(__dirname, "public", "favicon.ico")));
...
}
private routes {...}
}
我插入了myapp / public / favicon.ico图片,localhost上没有显示任何内容:8080,无论如何要显示它?
更新 即可。将TS转换为JS后的app目录结构
dist
app
|_ interfaces (...)
|_ models (...)
|_ public
| |_ favicon.ico
|
|_ routes (...)
|_ schemas. (...)
|_ test (...)
|_ views (...)
|_ route.js
|_ server.js