jade

详解如何从零开始搭建Express+Vue开发环境

人盡茶涼 提交于 2019-12-07 02:10:47
准备工作 1. 为前端选择合适的预处理工具和资源管理工具 预处理工具又分为 js 预处理工具和 css 预处理工具。Javascript 一直以来最为人诟病的一点就是缺乏原生的模块机制,所有 js 代码文件在被 html 页面引入后将共用同一个命名空间。所以才出现了各种“标准”尝试解决这个问题,但他们都不是原生的,需要额外的工具对代码进行特殊处理。虽然 ES6 终于引入了模块机制,但以现在的浏览器支持程度,还不足以“毫无顾虑地随拿随用”。所以 js 预处理工具最主要的工作就是帮助解决 js 的模块问题。而 css 预处理工具则很好理解,就是把 sass,less 或者 stylus 代码翻译、合并成 css 代码。 资源管理工具则是帮我们管理前端所需的各种资源文件(比如 css、js、图片、字体等等),便于我们引用。目前常用的解决方法是将他们直接编码进 js 代码中,然后像引用 js 模块一样引用它们。这可比手写各种 url 方便多了。 正如标题所说,我们将采用 Webpack,因为它具备上面所说的所有功能。此外还支持代码热替换,使修改代码后不用刷新页面也能在浏览器中立即看到效果。 2. 为后端选择合适的预处理工具 后端面对的都是 js 代码,不需要前端那样的资源管理工具,另外, Node 强迫你使用至少一种模块管理方案(CommonJS 或 ES6 的 import)

nodejs实践--npm使用、express创建ejs模板

我怕爱的太早我们不能终老 提交于 2019-12-06 21:40:43
Node Express在命令行创建项目时,默认是使用Jade模板,虽然这个模板高效,但毕竟跟普通html风格相差甚远,很多人用不习惯。 ejs风格,简单、直观、明了,和:jsp php asp freemaker 类似,在页面嵌套。 1、NPM创建Node项目 > npm init 1、EXPRESS创建Node项目 注:运行命令前记得先进入当前项目所在的目录。 如果出现错误:'express' 不是内部或外部命令,也不是可运行的程序或批处理文件 请全局安装 express和express-generator 在终端上执行以下代码 npm install -g express npm install -g express-generator [Jade模板] > express nodeJade express创建项目若不显示指定模板,默认使用Jade,以下写法都可以: express -jade nodeJade express -view=jade nodeJade express --view=jade nodeJade (官方推荐写法) [EJS模板] express -e nodeEjs //参数 -e 就是说用ejs引擎,dirName就是创建项目的目录 以下写法都可以: ### EJS模板需要显示指定 express --ejs nodeEjs express -

10k前端工程师应该会什么?

北战南征 提交于 2019-12-05 09:06:05
前些日子,在某论坛看到一帖,问「一线城市中小公司的前端10k应该会什么?」,下面有很多回答,大多数回答的是一些会前端三大基础啊,html,css,JavaScript这些,然后一两个框架。实在是太笼统了,这回做一个总结,写下来,也让更多对编程,对前端感兴趣,并想以此为饭碗的朋友们多了解一下! 以下是匿名用户的回答: 毕业一年,工资9.5k,加上补贴奖励, 税后10.5k左右 。 1. html、css、js基础自我感觉良好。语义化、写点css3动画、写写原生js等。 2. 在学校期间就学了前端用jq、bootstrap做过一些项目,学了vue基础,能简单搭个vue项目。 3. webpack只能说会用,一般直接配置有些api记得不清楚,需找文档,主要是不用常配,基本项目开头配置一次,中期优化配置。 4. vue前后做了2个商业项目(公司主要用的vue+elementUI)。 5. react未做过项目,自己找些网站模仿着写点东西(没机会用react做项目)。 6. 代码基本用上ES6,还有async/await等一些语法。 7. 略懂一些常见简单的优化,js优化、懒加载等等。 8. node的话看过视频跟着做了一个小项目,那时候还学了点mongodb、jade等(不过好久没用,忘记7788了),现在和react配合着,ts+koa+Graphql作为中间层,react

pug学习

本秂侑毒 提交于 2019-12-04 16:07:42
pug学习 jade(pug) 由于商标版权问题,jade已经改名为Pug。 Pug 是一个高性能的模板引擎,它是用 JavaScript 实现的,并且可以供 Node 使用,当然还支持其他语言。 文件后缀名为.pug(.jade) pug优点 可读性高 灵活的缩进 块展开 代码默认经过编码处理(转义),安全性高 运行时和编译时上下文错误报告 支持命令行编译 支持html5模式 在内存中缓存(可选) 原生支持 Express 合并动态和静态标签类 过滤器 安装 npm安装 建议安装个nrm来进行源管理 npm install pug -g npm install pug-cli -g 测试demo 为了方便编写代码,最好把编译器的tab设置:2. // index.jade doctype html html head title jade test body h2 jade study 粗暴的编译方法 // index.html <!DOCTYPE html><html><head><title>jade test</title></head><body><h2>jade study </h2></body></html> 发现编译后的代码不具备可读性 pug -- help Options: -P, --pretty compile pretty HTML output ##

pug的安装与使用

ぃ、小莉子 提交于 2019-12-04 16:04:40
说明 Pug 原名不叫Pug,是大名鼎鼎的jade,后来由于商标的原因,改为Pug,哈巴狗。其实只是换个名字,语法都与jade一样。丑话说在前面,Pug有它本身的缺点——可移植性差,调试困难,性能并不出色,但使用它可以加快开发效率。本文将详细介绍pug模板引擎。 安装 1.sudo npm install jade -g 2.sudo yarn global add jade 常用命令 普通编译,会在同目录下生成编译后的 test.html 文件 jade test.jade # --pretty | -P (大写) 美化输出的 html 使之带有缩进等 jade -P test.jade # --out | -o <dir> 将编译后的 html 输出到指定文件夹 jade -P test.jade --out ./output # --obj | -O <path|str> 向 jade 模板中传递变量,需要传递一个 json 或者一个 json 文件的路径 jade -P --obj '{testName: "this is tetsName"}' test.jade jade -P -O ./config.json test.jade # --watch | -w 监听文件变化,自动重新编译 jade -P -w test.jade 标签 jade 中的标签不再含有

Submit Jade form

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the error with the following Jade form template? I can't get it to submit values. div form(action='/signup',method='post') div(data-role='fieldcontain') fieldset(data-role='controlgroup') label(for='email') email input(id='email',type='text',value='',placeholder='@') div#passworddiv(data-role='fieldcontain') fieldset(data-role='controlgroup label(for='password') password input(id='password',type='password',value='',placeholder='') div(id='hiddendiv',data-role='fieldcontain') fieldset(data-role='controlgroup') label(for='hidden

nodeJs学习-08 模板引擎 jade、ejs

寵の児 提交于 2019-12-03 04:44:59
模板引擎   jade -破坏式、侵入式,强依赖;用了之后不能随便用别的引擎   ejs - 温和、非侵入时、弱依赖 jade使用 const jade = require('jade'); var str = jade.renderFile('./views/8.jade', { pretty: true, //美化 调试时使用 }); console.log(str); ejs使用 const ejs=require('ejs'); ejs.renderFile('./views/1.ejs', {name: 'blue'}, function (err, data){ if(err) console.log('编译失败'); else console.log(data); }); jade语法:   自动识别单标签 实例:属性script(src="a.js") link(href="a.css",rel="stylesheet")input(type="text",id="txt1",value="abc")div&attributes({title: 'aaa', id: 'div1'}) 标签内部值a(href="http://www.baidu.com/") 百度 样式div(style="width:200px;height:200px;background:red

Is there a Jade template syntax checker/validator?

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some syntax errors in my Jade templates. Are there any tools that can help me debug? 回答1: Found it. Use jade [fileName].jade to debug your Jade template. You can install the Jade tool with npm install jade --global . 回答2: Adding this here because I still had to google. npm i -g pug-lint NOTE: jade has changed its name to pug 回答3: web storm is a better tool for jade development ,it idents and corrects jade files 文章来源: Is there a Jade template syntax checker/validator?

AngularJS ui-router : Could not resolve___ from state ___ Error

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am following along on this year old ui-router tutorial http://txt.fliglio.com/2013/05/angularjs-state-management-with-ui-router/ and I'm getting the following error: Error: Could not resolve 'settings/quotes' from state 'settings' I am fitting this tutorial app into my Express.JS setup and I'm using Jade for my templates. All the Jade templates seem to be rendering properly but I am noticing that there is no href being created for the User Quotes ( settings/quotes URL) ui-sref link. Maybe there is a clue there. You can see this in the

Error: No default engine was specified and no extension was provided

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working through setting up a http server using node.js and engine. However, I keep running into issues that I have little information on how to resolve I would appreciate some help solving this please. Thanks in advance. Error: No default engine was specified and no extension was provided. at new View (...\node_modules\express\lib\view.js:41:42) at Function.app.render (...\node_modules\express\lib\application.js:484:12) at ServerResponse.res.render (...\node_modules\express\lib\response.js:783:7) at Layer.handle (...\app.js:123:7) at