唯品会顺丰快递面单模板

Express is capable of handling server-side template engines.

Express能够处理服务器端模板引擎。

Template engines allow us to add data to a view, and generate HTML dynamically.

模板引擎允许我们向视图添加数据,并动态生成HTML。

Express uses Jade as the default. Jade is the old version of Pug, specifically Pug 1.0.

Express使用Jade作为默认设置。 Jade是Pug的旧版本,特别是Pug 1.0。

The name was changed from Jade to Pug due to a trademark issue in 2016, when the project released version 2. You can still use Jade, aka Pug 1.0, but going forward, it’s best to use Pug 2.0

由于该项目在2016年发布了版本2,由于商标问题,名称从Jade更改为Pug。您仍然可以使用Jade,又名Pug 1.0,但今后最好使用Pug 2.0

Although the last version of Jade is 3 years old (at the time of writing, summer 2018), it’s still the default in Express for backward compatibility reasons.

尽管Jade的最新版本已经3年了(在撰写本文时,2018年夏季),但出于向后兼容的原因,它仍然是Express中的默认版本。

In any new project, you should use Pug or another engine of your choice. The official site of Pug is https://pugjs.org/.

在任何新项目中,都应使用Pug或您选择的其他引擎。 Pug的官方网站是https://pugjs.org/ 。

You can use many different template engines, including Pug, Handlebars, Mustache, EJS and more.

您可以使用许多不同的模板引擎,包括Pug,车把,Mustache,EJS等。

使用哈巴狗 (Using Pug)

To use Pug we must first install it:

要使用Pug,我们必须首先安装它:

npm install pug

and when initializing the Express app, we need to set it:

在初始化Express应用时,我们需要对其进行设置:

const express = require('express')
const app = express()
app.set('view engine', 'pug')

We can now start writing our templates in .pug files.

现在,我们可以开始在.pug文件中编写模板了。

Create an about view:

创建一个关于视图:

app.get('/about', (req, res) => {res.render('about')
})

and the template in views/about.pug:

views/about.pug的模板:

p Hello from Flavio

This template will create a p tag with the content Hello from Flavio.

该模板将创建一个p标签,其内容Hello from Flavio

You can interpolate a variable using

您可以使用

app.get('/about', (req, res) => {res.render('about', { name: 'Flavio' })
})

p Hello from #{name}

This is a very short introduction to Pug, in the context of using it with Express. Look at the Pug guide for more information on how to use Pug.

与Express一起使用时,这是对Pug的简短介绍。 有关如何使用帕格的更多信息,请参阅帕格指南 。

If you are used to template engines that use HTML and interpolate variables, like Handlebars (described next), you might run into issues, especially when you need to convert existing HTML to Pug. This online converter from HTML to Jade (which is very similar, but a little different than Pug) will be a great help: https://jsonformatter.org/html-to-jade

如果习惯于使用HTML和内插变量的模板引擎,例如Handlebars(如下所述),则可能会遇到问题,尤其是当您需要将现有HTML转换为Pug时。 这个从HTML到Jade的在线转换器(非常相似,但与Pug稍有不同)将提供很大的帮助: https : //jsonformatter.org/html-to-jade

Also see the differences between Jade and Pug

另请参阅Jade和Pug之间的区别

使用车把 (Using Handlebars)

Let’s try and use Handlebars instead of Pug.

让我们尝试使用把手代替帕格。

You can install it using npm install hbs.

您可以使用npm install hbs进行npm install hbs

Put an about.hbs template file in the views/ folder:

about.hbs模板文件放在views/文件夹中:

Hello from {{name}}

and then use this Express configuration to serve it on /about:

然后使用此Express配置在/about上投放:

const express = require('express')
const app = express()
const hbs = require('hbs')app.set('view engine', 'hbs')
app.set('views', path.join(__dirname, 'views'))app.get('/about', (req, res) => {res.render('about', { name: 'Flavio' })
})app.listen(3000, () => console.log('Server ready'))

You can also render a React application server-side, using the express-react-views package.

您还可以使用express-react-views包在服务器端渲染React应用程序。

Start with npm install express-react-views react react-dom.

npm install express-react-views react react-dom开始, npm install express-react-views react react-dom

Now instead of requiring hbs we require express-react-views and use that as the engine, using jsx files:

现在,我们不再需要hbs而是需要express-react-views并使用jsx文件将其用作引擎:

const express = require('express')
const app = express()app.set('view engine', 'jsx')
app.engine('jsx', require('express-react-views').createEngine())app.get('/about', (req, res) => {res.render('about', { name: 'Flavio' })
})app.listen(3000, () => console.log('Server ready'))

Just put an about.jsx file in views/, and calling /about should present you an “Hello from Flavio” string:

只需将一个about.jsx文件放在views/ ,然后调用/about您显示“来自Flavio的Hello”字符串:

const React = require('react')class HelloMessage extends React.Component {render() {return <div>Hello from {this.props.name}</div>}
}module.exports = HelloMessage

翻译自: https://flaviocopes.com/express-templating/

唯品会顺丰快递面单模板

唯品会顺丰快递面单模板_快递模板相关推荐

  1. 概要设计和详细设计模板_网站模板不用设计 直接下载免费网站模板

    今天给大家分享几个下载网站模板的网站,国外精品网站模板,设计风格大气,思路清晰,可下载,可学习别人的设计理念和制作方法,非常不错的几个网站,强烈建议收藏了. 一.Awwwards 精挑细选世界各地的最 ...

  2. 2022上海国际快递物流产业博览会_快递物流展_物流展_快递展

    2022上海国际快递物流产业博览会 内部物流装备/智慧物流/冷链物流/智慧仓配一体化/新能源物流车/绿色包装与材料   2022年3月17-19日 | 上海新国际博览中心 主办单位:上海市快递行业协会 ...

  3. 商城模板_商城模板网站html5_微信小程序商城模板

    分享一个商城模板平台,商城模板网站html5平台,微信小程序商城模板平台,这个平台可以提供超60+行业的商城模板. ☞商城模板平台 另外给大家分享一下,在这个商城模板平台可以制作商城网站,电脑商城和微 ...

  4. VS2019怎么没有C++的窗体应用模板_砖混结构模板技术交底

    砖混结构模板 本技术交底适用于工业与民用建筑砖混结构,外墙内模和外板内模结构构造柱.圈梁.板缝的支模板工程. 1.材料设备要求 (1)木板(厚度为20-50mm),定型组合钢模板(长度为600.750 ...

  5. java 前端模板_前端模板引擎入门

    模板引擎 模板引擎 起到 数据和视图分离的作用, 模板对应视图, 关注如何展示数据, 在模板外头准备的数据, 关注那些数据可以被展示. 后端模板引擎 freemarker 如下介绍,  java后台的 ...

  6. python生成快递取件码_快递,顺丰,python,截图,15Seconds

    快递批量截图查询工具已经更新到3.0版本了,从1.0版本至今大概有半年时间了,期间收到粉丝们很多不错的反馈和建议,也感谢粉丝提供的大量测试样本,使3.0版本对快递查询的出错率和稳定性有了质的改善,并增 ...

  7. 制作模板_木模板制作流程

    木模板制作流程: 1.采用松木和桉木.木模板采用马尾松木面板,国产桉木做芯板,板面平整光亮,锯开无空洞,模板周转次数高 . 2.刨制成单板.木模板要求所有单板(无论是芯板还是面板)必须是无破损的一级板 ...

  8. java定义类模板_定义模板——函数模板和类模板

    面向对象编程(OOP)和泛型编程都能处理在编写程序时不知道类型的情况.不同之处在于:OOP能处理类型在程序运行之前都未知的情况:而在泛型编程中,在编译时就能获知类型了. 前面介绍的容器.迭代器和算法都 ...

  9. 顺丰快递单号的规律_顺丰快递顺丰快递查询单号查询

    查询快递前:请先点击上面蓝字"  顺风快递快件单号查询"关注,关注后即可免费查询快递! 顺丰快递       顺丰快递查询      顺丰快递单号查询 记下货物的订单号码. 打开顺 ...

  10. 丰巢“羊毛”,出在快递身上,让用户买单!

    点击"技术领导力"关注∆  每天早上8:30推送 作者| Mr.K   编辑| Emma 来源| 技术领导力(ID:jishulingdaoli) 4月30日,丰巢宣布,普通会员超 ...

最新文章

  1. public static final int REMIN_REQUEST_CODE = 0x911 自己的大致理解
  2. svm通俗讲解_机器学习算法:SVM
  3. GDCM:gdcm::StreamImageReader的测试程序
  4. 压缩包安装mySQL 与 Qt中使用mySQL
  5. html2image乱码问题,HtmlImageGenerator字体乱码问题解决、html2image放linux上乱码问题解决...
  6. arcgis报错常用解决方法
  7. oracle sql语句 从指定条数查询
  8. Element表单验证(2)
  9. 【原创】大端和小端字节序的细节
  10. js休眠实现sleep[博]
  11. bat 自动输入密码_「docker实战篇」python的docker爬虫技术移动自动化uiautomator工具(16)...
  12. 【天意使用教程系列】破解系统登录密码
  13. 单片机原理及应用c51语言版林立,单片机原理及应用——基于Proteus和Keil C(第4版)...
  14. 网络协议分析-TCP协议分析
  15. 关于静态博客的评论系统
  16. java opencv 基本操作4
  17. 鼠标悬停放大图片特效
  18. [音乐天堂]辛德勒名单原声大碟
  19. Excel vba 调用outlook发送邮件
  20. 阿里云直播生成推流和播流地址类

热门文章

  1. [unity]调用手机摄像头
  2. Office 2010 安装程序包的语言不受系统支持
  3. Unity调用安卓文件管理器
  4. 【PC工具】PC好用的迅雷下载版本合集,hash资源下载方法,石皮版迅雷软件去广告优化增强典藏版...
  5. Django项目(五):注册模块—登录注册
  6. 【jQWidgets】API 笔记
  7. pvr.ccz 与 png 格式 互转的解决方案
  8. mysql面试题总结_mysql面试题小结
  9. Unity3d 真实的植物渲染
  10. 20221118-数学函数图像在线工具推荐