我在Express,Mongo和Jade上大致學習了這個教程,儘管我已經成功地從mongo中取回了一些數據,但是jade並沒有渲染我的頁面。 http://blog.ijasoneverett.com/2013/03/a-sample-app-with-node-js-express-and-mongodb-part-1/爲什麼我的玉指標頁是空白的?
片段有:
app.js:
app.get('/', function(req, res) {
employeeProvider.findAll(function(error, emps) {
// adding logging here shows that 'title' and 'emps' are correctly populated
res.render('index', { title:'Employees', employees:emps });
});
});
layout.jade:
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
index.jade:
extends layout
block content
h1= title
div
each employee in employees
div.employee
div.created_at= employee.created_at
div.title= employee.title
div.name= employee.name
WHE n個I提取瀏覽器中顯示的頁面的源代碼,它只是表明這一點:
<!DOCTYPE html><html><head><title>Employees</title><link rel="stylesheet" href="/stylesheets/style.css"></head><body></body></html>
其實也沒什麼,我把jade.index簡化它似乎得到呈現。例如,這也使得一個空白頁:
index.jade:
extends layout
block content
h1= title
我認爲這些文件應該叫'index.jade'和'layout.jade',而不是'jade.index'等。 – Sergey
的確你是對的,它們被稱爲index.jade等。我換成了I打出我的問題。我將編輯該問題。謝謝 – user1593388