【发布时间】:2020-06-16 20:12:16
【问题描述】:
将部分(ejs 模板)添加到页面时,本地主机未加载。如果未添加部分,则页面首先加载。但添加部分后,页面不再加载。也没有错误报告。页面不断加载,最后显示无法访问该地址。
var express = require("express");
var app = express();
var bodyparser = require("body-parser");
app.use(bodyparser.urlencoded({extended: true}));
app.set("view engine", "ejs");
app.get("/", function(req , res){
res.render("landing");
});
app.get("/campgrounds", function(req,res){
res.render("campgrounds",{campgrounds:campgrounds});
});
app.post("/campgrounds",function(req,res){
var name = req.body.name;
var image = req.body.image;
var newCamp = {name: name, image:image}
campgrounds.push(newCamp)
res.redirect("/campgrounds");
});
app.get("/campgrounds/new", function(req, res){
res.render("new.ejs");
});
app.listen(3000, function(){
console.log("Yelp camp server has started");
});
当标题添加到以下页面时,页面不再加载
<%- include('partials/header.ejs') %>
<h1>landing page</h1>
<a href="/campgrounds">view all campgrounds</a>
<p>asdasdasda</p>
<%- include('partials/footer.ejs') %>
请帮忙!!!! 这里也是标题的代码
<!DOCTYPE html>
<html>
<head>
<title>YELPCAMP</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
</head>
<body>
<p>header tabs</p>
【问题讨论】:
-
没用。这仅在添加页眉时发生。如果添加页脚来代替页眉,它就可以工作。但是当添加标题时它不起作用```