日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pug使用方法

發布時間:2023/12/18 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pug使用方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝

npm install pug-cli -g? 全局安裝

開始監聽

pug -w ./ -o ./html -P

-w? 開始監聽

./html? 放入文件夾

-P? 規范代碼

?基j基本語法

?

?

?

id?和 class

?

標簽中的屬性

doctype html htmlheadbodyinput(type="password" name="inpPwd" data-js=`${ 1 > 2 ? "ok" : "notok"}`)- const myClasses = ["class1", "class2", "class3"]div(class=myClasses)div.mydiv(class=myClasses)- const myStyles = {"color": "red", "background-color": "blue"}div(style=myStyles)- const myAttrbutes = {"src": "myPhoto.png", "alt": "this is my photo"}img&attributes(myAttrbutes)input(type="text" disabled)input(type="text" disabled=false) <!DOCTYPE html> <html><head></head><body><input type="password" name="inpPwd" data-js="notok"><div class="class1 class2 class3"></div><div class="mydiv class1 class2 class3"></div><div style="color:red;background-color:blue;"></div><img src="myPhoto.png" alt="this is my photo"><input type="text" disabled><input type="text"></body> </html>

引入css

doctype html htmlheadlink(rel="stylesheet" href="style.css")style.p{color: red;text-decoration: underline;}bodyp this is a html filep(style="text-align: center; text-transform: uppercase") this is a html file- const pStyles = {"text-align": "center", "text-transform": "uppercase"};p(style=pStyles) file2 <!DOCTYPE html> <html><head><link rel="stylesheet" href="style.css"><style>p{color: red;text-decoration: underline;}</style></head><body><p>this is a html file</p><p style="text-align: center; text-transform: uppercase">this is a html file</p><p style="text-align:center;text-transform:uppercase;">file2</p></body> </html>

循環

doctype html htmlheadbodyh1 for / each loopeach n in [50, 2, 3, 4, 5]p= neach n,i in [50, 2, 3, 4, 5]p= n + "-" + i- const names = ["aaa", "bbb", "ccc"]each n, i in namesp= n + "-" + i-const grades = {"web dev": 85, "software design": 76}each n, i in gradesp= n + "-" + ifor n, i in []p= n + "-" + ielse strong "no values are here!" <!DOCTYPE html> <html><head></head><body><h1>for / each loop</h1><p>50</p><p>2</p><p>3</p><p>4</p><p>5</p><p>50-0</p><p>2-1</p><p>3-2</p><p>4-3</p><p>5-4</p><p>aaa-0</p><p>bbb-1</p><p>ccc-2</p><p>85-web dev</p><p>76-software design</p><strong>"no values are here!"</strong></body> </html>

條件判斷

doctype html htmlheadbodyh2 my web application- let user = {name: "domenic", loggedIn: false, lastLogin: 6}if user.loggedInpI welcome back,strong #{ user.name }else if user.lastLogin < 10p your last login was #{ user.lastLogin } minutes agop a(href="/login") log in againelsea(href="/login") Log in <!DOCTYPE html> <html><head></head><body><h2>my web application</h2><p>your last login was 6 minutes ago</p><p> <a href="/login">log in again</a></p></body> </html>

多路分支

doctype html htmlheadbody- const orderStates = 'Pending'case orderStateswhen 'Pending'p your order has been palced and will be sent shortlywhen 'In_Transit'p 22222222222when 'Completed'p 33333333333defaultp 44444444444 <!DOCTYPE html> <html><head></head><body><p>your order has been palced and will be sent shortly</p></body> </html>

?

總結

以上是生活随笔為你收集整理的pug使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。