无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Vue3+Vite+Vant-UI 開發(fā)雙端招聘APP [獨(dú)家首發(fā)持續(xù)更新]

2023-08-14 12:09 作者:bili_51805000088  | 我要投稿

Vue3+Vite+Vant-UI 開發(fā)雙端招聘APP [獨(dú)家首發(fā)持續(xù)更新]

download:https://www.zxit666.com/6479/

解析 CSS 規(guī)則?parseRule()

private parseRule() { ? ?const rule: Rule = { ? ? ? ?selectors: [], ? ? ? ?declarations: [], ? ?} ? ?rule.selectors = this.parseSelectors() ? ?rule.declarations = this.parseDeclarations() ? ?return rule }

在?parseRule()?里,它分別調(diào)用了?parseSelectors()?去解析 CSS 選擇器,然后再對(duì)剩余的 CSS 文本執(zhí)行?parseDeclarations()?去解析 CSS 屬性。

解析選擇器?parseSelector()

private parseSelector() { ? ?const selector: Selector = { ? ? ? ?id: '', ? ? ? ?class: '', ? ? ? ?tagName: '', ? ?} ? ?switch (this.rawText[this.index]) { ? ? ? ?case '.': ? ? ? ? ? ?this.index++ ? ? ? ? ? ?selector.class = this.parseIdentifier() ? ? ? ? ? ?break ? ? ? ?case '#': ? ? ? ? ? ?this.index++ ? ? ? ? ? ?selector.id = this.parseIdentifier() ? ? ? ? ? ?break ? ? ? ?case '*': ? ? ? ? ? ?this.index++ ? ? ? ? ? ?selector.tagName = '*' ? ? ? ? ? ?break ? ? ? ?default: ? ? ? ? ? ?selector.tagName = this.parseIdentifier() ? ?} ? ?return selector }private parseIdentifier() { ? ?let result = '' ? ?while (this.index < this.len && this.identifierRE.test(this.rawText[this.index])) { ? ? ? ?result += this.rawText[this.index++] ? ?} ? ?this.sliceText() ? ?return result }

選擇器我們只支持標(biāo)簽稱號(hào)、前綴為?#?的 ID 、前綴為恣意數(shù)量的類名?.?或上述的某種組合。假如標(biāo)簽稱號(hào)為?*,則表示它是一個(gè)通用選擇器,能夠匹配任何標(biāo)簽。

規(guī)范的 CSS 解析器在遇到無(wú)法辨認(rèn)的局部時(shí),會(huì)將它丟掉,然后繼續(xù)解析其他局部。主要是為了兼容舊閱讀器和避免發(fā)作錯(cuò)誤招致程序中綴。我們的 CSS 解析器為了完成簡(jiǎn)單,沒(méi)有做這方面的做錯(cuò)誤處置。

解析 CSS 屬性?parseDeclaration()

private parseDeclaration() { ? ?const declaration: Declaration = { name: '', value: '' } ? ?this.removeSpaces() ? ?declaration.name = this.parseIdentifier() ? ?this.removeSpaces() ? ?while (this.index < this.len && this.rawText[this.index] !== ':') { ? ? ? ?this.index++ ? ?} ? ?this.index++ // clear : ? ?this.removeSpaces() ? ?declaration.value = this.parseValue() ? ?this.removeSpaces() ? ?return declaration }

parseDeclaration()?會(huì)將?color: red;?解析為一個(gè)對(duì)象?{ name: "color", value: "red" }。

小結(jié)

CSS 解析器相對(duì)來(lái)說(shuō)簡(jiǎn)單多了,由于很多學(xué)問(wèn)點(diǎn)在 HTML 解析器中曾經(jīng)講到。整個(gè) CSS 解析器的代碼大約 100 多行,假如你閱讀過(guò) HTML 解析器的源碼,置信看 CSS 解析器的源碼會(huì)更輕松。


Vue3+Vite+Vant-UI 開發(fā)雙端招聘APP [獨(dú)家首發(fā)持續(xù)更新]的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
弥渡县| 井冈山市| 太原市| 太仓市| 富阳市| 东乡族自治县| 呈贡县| 肃宁县| 昌邑市| 色达县| 荆门市| 胶州市| 克什克腾旗| 土默特右旗| 许昌市| 杭州市| 朝阳市| 西丰县| 霍林郭勒市| 和平区| 陈巴尔虎旗| 临朐县| 天镇县| 酒泉市| 会同县| 普安县| 绥化市| 香格里拉县| 高密市| 娱乐| 隆化县| 梅河口市| 基隆市| 肇庆市| 绥阳县| 绍兴市| 广河县| 泰宁县| 雷波县| 额尔古纳市| 惠东县|