最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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ó)家法律
瑞金市| 新郑市| 肃宁县| 岱山县| 徐州市| 沙河市| 蒙山县| 施秉县| 轮台县| 滨州市| 保亭| 泰顺县| 桃园市| 纳雍县| 青浦区| 香港 | 蕲春县| 旺苍县| 乌拉特后旗| 尤溪县| 当涂县| 新乡市| 南平市| 沭阳县| 水城县| 措勤县| 桃江县| 洞头县| 昭苏县| 廉江市| 东城区| 兴隆县| 边坝县| 三江| 梅河口市| 札达县| 凌云县| 长岭县| 咸宁市| 嫩江县| 西安市|