zoukankan      html  css  js  c++  java
  • express里如何将jade替换为html

    这里我将贴出核心代码


    app.js 文件如下

    app.use(logger('dev'));
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(cookieParser());
    app.use(express.static(path.join(__dirname, 'public')));
    
    app.use('/', routes);
    app.use('/users', users);
    
    
    app.use('/login', routes);//此处处理登陆


    路由(routes)文件下的index文件

    var express = require('express');
    var router = express.Router();
    
    
    
    /* GET home page. */
    router.get('/', function(req, res, next) {
      //res.render('index', { title: 'Express' });
      res.sendfile("./views/index.html");
    });
    
    
    router.get('/login', function (req, res, next) {
           res.render('login',{ title: '登录页面' });
         // res.sendfile("./views/login.html");
    });


    视图文件(views)文件夹下的jade改为html

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    </head>
    <body>
     <table>
                  <h1><%=title%></h1>
             <tr>
             <td >用户名</td>
                 <td><input type="text" name="name" value=""></td>
             </tr>
             <tr>
                 <td >密码</td>
                 <td><input type="text" name="pwd" value=""></td>
             </tr>
     </table>
    </body>
    </html>
  • 相关阅读:
    Qt第一个小程序(使用vs2017开发)
    Qt资料大全
    Win10+MSVC2017+QT5.9.4开发环境
    小波去噪的基本知识
    RxJava Map操作详解
    Tomcat提示Null component
    章节目录
    BeanDefinition的载入和解析
    org.springframework.util.Assert
    使用Eclipse maven构建springmvc项目
  • 原文地址:https://www.cnblogs.com/majiabin/p/4716397.html
Copyright © 2011-2022 走看看