求指导,关于express的静态目录
发布于 1年前 作者 x372563572 929 次浏览

使用express把静态指向public目录 public/css/xxx.css

浏览器直接访问/css/xxx.css可以输出内容, 怎么才能让浏览器访问/css这个路径输出目录结构啊

4 回复

app.use(express.static(__dirname + ‘/dist’));

这个是配置静态目录吧。我是想输出静态目录结构,就像apache作为server,访问静态目录下的子目录,会列出该目录下的文件列表那样

i don’t think it has something like that. if you want static listing, you can write an html or ask node to list the file and send back the json.

if you really want that then just use apache or nginx. node or express is not meant to be a static server.

回到顶部