我是一个菜鸟,正在使用mean.js样板。
我已创建了一些路线,但我遇到了问题,当我导航到某条路线时(&#39; / articles&#39;)我得到的服务器输出如下:< / p>
[{&#34; _id&#34;:&#34; 5553aa4116a2fddc830b0f66&#34;&#34;使用者&#34; {&#34; _id&#34;:&#34; 5552398fcf7ada7563db68b7&#34; &#34;显示名&#34;:&#34;莫 Bazazi&#34;}&#34; __ V&#34;:0,&#34;内容&#34;:&#34; WAHATTATA&#34;&#34;标题&#34;:&#34;第五 实施例&#34;&#34;创建&#34;:&#34; 2015-05-13T19:47:13.905Z&#34;}]
但我想渲染渲染的视图,即使我手动输入路线 - 是否有人有任何建议?
这是我的快速配置的一部分
use strict';
/**
* Module dependencies.
*/
var fs = require('fs'),
http = require('http'),
https = require('https'),
express = require('express'),
morgan = require('morgan'),
bodyParser = require('body-parser'),
session = require('express-session'),
compress = require('compression'),
methodOverride = require('method-override'),
cookieParser = require('cookie-parser'),
helmet = require('helmet'),
passport = require('passport'),
mongoStore = require('connect-mongo')({
session: session
}),
flash = require('connect-flash'),
config = require('./config'),
consolidate = require('consolidate'),
path = require('path');
module.exports = function(db) {
// Initialize express app
var app = express();
// Globbing model files
config.getGlobbedFiles('./app/models/**/*.js').forEach(function(modelPath) {
require(path.resolve(modelPath));
});
// Setting application local variables
app.locals.title = config.app.title;
app.locals.description = config.app.description;
app.locals.keywords = config.app.keywords;
app.locals.facebookAppId = config.facebook.clientID;
app.locals.jsFiles = config.getJavaScriptAssets();
app.locals.cssFiles = config.getCSSAssets();
// Passing the request url to environment locals
app.use(function(req, res, next) {
res.locals.url = req.protocol + '://' + req.headers.host + req.url;
next();
});
// Should be placed before express.static
app.use(compress({
filter: function(req, res) {
return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
},
level: 9
}));
// Showing stack errors
app.set('showStackError', true);
// Set swig as the template engine
app.engine('server.view.html', consolidate[config.templateEngine]);
// Set views path and view engine
app.set('view engine', 'server.view.html');
app.set('views', './app/views');
所以Claies是对的 - 这是一个HTML5问题 - 我一直在努力解决这个问题并试图为快速配置设置一个全部 - 我已经在下面添加了这一部分:
// Setting the app router and static folder
app.use(express.static(path.resolve('./public')));
app.get('/', function(req, res) {
res.render('index');
});
// Globbing routing files
config.getGlobbedFiles('./app/routes/**/*.js').forEach(function(routePath) {
require(path.resolve(routePath))(app);
});
app.get('*', function(req, res) {
res.redirect('/');
});
问题在于我使用了mean.js样板,并且他们有自定义的基于glob的路由,这对我的捕获并不好用,即我的资源不能正常使用它们,虽然他们正在改变正确的模板 - 任何想法?