Node rendered HTML file not finding relative path Scripts

前端 未结 1 1799
我在风中等你
我在风中等你 2021-01-13 03:09

New to node, and have it running pulling in an HTML page using Express and EJS

app.set(\'views\', __dirname + \'/views\');
app.engine(\'html\', require(\'ejs         


        
1条回答
  •  不思量自难忘°
    2021-01-13 03:45

    you should configure express to server static files, for example, put all the static files under a directory called 'public'

    app.configure(function () {
        app.use(express.cookieParser());
        app.use(express.bodyParser());
        app.use('/public', express.static(__dirname + '/public'));
        app.use(app.router);    
    });
    

    then in your html:

        
    

    0 讨论(0)
提交回复
热议问题