1jade(模板引擎)
使用jade解析字符串
下载jade(命令:cnpm install jade/npm install jade)
2
//引入jade
const jade=require('jade');
//解析字符串
var str=jade.render('div');
console.log(str);
解析出来的样式如下:图中的div
JVK)AO1H`U}H8Q_6~8WM{1S.jpg
3 解析文件
创建一个名为 ***.jade 的文件 名字可以随便起
html
head
body
a(href="http://www.baidu.com")
input(type="text",name="uname",value="用户名")
input(type="password",name="upwd",value="密码")
input(type="submit",value="提交")
h1 qwertyuiop
div(style="width:100px;height:100px;background:red")
div(style={width:"100px",height:"100px",background:"red"})
p(class="a b c")
p(class=['a','b','c'])
a(href="www.baidu.com")去百度
p 你好啊
span 我很好
解析出来的样式如下:
![T52]50S97PB3Q{9]L)3J@19.jpg](https://img.haomeiwen.com/i13984212/b2a4a77e07d366f5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
网友评论