CSS找不到Dyson模块节点

我在Node js上使用Dyson模块,但我的应用程序没有findcss文件夹。 我有这个:

/demoDyson dyson-demo.js /node_modules /public /css style.css /services /GET _index.js test.js 

dyson-demo.js

 var express = require('express'), dyson = require('dyson'), path = require('path'); dyson.bootstrap({ configDir: __dirname + '/services', port: 8765 }); var myApp = express(); myApp.use(express.static(path.join(__dirname, 'public'))); 

_index.js

 module.exports = { path: '/', render: function(req, res) { var html = '<h1>dyson</h1><p>Example endpoints:</p>'; var examples = [ '/test' ]; html += '<ul>' + examples.map(function(example) { return '<li><a href="' + example + '">' + example + '</a></li>'; }).join('') + '</ul>'; res.send(200, html); } }; 

test.js

 var path = require('path'); module.exports = { path: '/test', render: function (req, res) { res.sendFile(path.resolve(__dirname + '/../../public/index.html')); } }; 

现在,要在公用文件夹中加载index.html文件,浏览器控制台会提示找不到该css文件。 有任何想法吗?

在运行dyson API时,它不会与express中间件结合使用。 我build议你做的只是使用'./' + pathToTheFile或者你可以上传你的css文件在线以.css扩展名,然后将其链接到您的HTML。