nodejs express安装
发布日期:2021-08-18 16:37:28 浏览次数:9 分类:技术文章

本文共 1130 字,大约阅读时间需要 3 分钟。

转载自

1. 安装express库

1、npm install -g express-generator@4   #全局安装 -g
2、express -V   #检查版本

  3、使用express的命令,来创建项目了。

4、进入项目目录,下载依赖库,构建项目

5、启动项目  npm start

 6、项目启动成功,打开浏览器 http://localhost:3000,就可以看到显示的页面了。

 

2. 目录结构

接下来,我们详细看一下Express4项目的结构、配置和使用。

  • bin, 存放启动项目的脚本文件
  • node_modules, 存放所有的项目依赖库。
  • public,静态文件(css,js,img)
  • routes,路由文件(MVC中的C,controller)
  • views,页面文件(Ejs模板)
  • package.json,项目依赖配置及开发者信息
  • app.js,应用核心配置文件

3. Bootstrap界面框架

编辑views/index.ejs文件

      <%= title %>    

<%= title %>

This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.

Learn more

  效果如下:

把index.ejs页面切分成3个部分:header.ejs, index.ejs, footer.ejs,用于网站页面的模块化。 

编辑header.ejs。

      <%= title %>    

 编辑footer.ejs。

      

编辑index.ejs

<% include header.ejs %>

<%= title %>

This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.

Learn more

<% include footer.ejs %>

  

转载于:https://www.cnblogs.com/xwtbk/p/7125019.html

转载地址:https://blog.csdn.net/weixin_30897233/article/details/97389803 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:判断一个整数是否是2的N次方
下一篇:域名dns查询_查询域名dns ip地址

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月08日 16时24分42秒