av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)VUE3教程:Vue3.0attribute強制行為

信息

大悟網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項目制作,到程序開發(fā),運營維護(hù)。創(chuàng)新互聯(lián)公司2013年成立到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。

這是一個低級的內(nèi)部 API 更改,不會影響大多數(shù)開發(fā)人員。

#概覽

下面是對這些變化的高層次總結(jié):

  • 刪除枚舉 attribute 的內(nèi)部概念,并將這些 attribute 視為普通的非布爾 attribute
  • 重大改變:如果值為布爾值,則不再刪除 attribute false。相反,它被設(shè)置為 attr=“false”。移除 attribute,使用 null 或者 undefined。

如需更深入的解釋,請繼續(xù)閱讀!

#2.x 語法

在 2.x,我們有以下策略來強制 v-bind 的值:

  • 對于某些 attribute/元素對,Vue 始終使用相應(yīng)的 IDL attribute(property):比如 value,,``,等等。
  • 對于“布爾 attribute”和 xlinks,如果它們是 falsy 的,Vue 會移除它們 (undefinednull or false) 另外加上它們 (見這里和這里)。
  • 對于“枚舉 attribute” (目前 contenteditable,draggablespellcheck),Vue 會嘗試強制將它們串起來 (目前對 contenteditable 做了特殊處理,修復(fù) vuejs/vue#9397)。
  • 對于其他 attribute,我們移除了 falsy 值 (undefinednull,or false) 并按原樣設(shè)置其他值 (見這里)。

下表描述了 Vue 如何使用普通非布爾 attribute 強制“枚舉 attribute”:

綁定表達(dá)式 foo 正常 draggable 枚舉
:attr="null"/draggable="false"
:attr="undefined"//
:attr="true"foo="true"draggable="true"
:attr="false"/draggable="false"
:attr="0"foo="0"draggable="true"
attr=""foo=""draggable="true"
attr="foo"foo="foo"draggable="true"
attrfoo=""draggable="true"

從上表可以看出,當(dāng)前實現(xiàn) true 強制為 'true' 但如果 attribute 為 false,則移除該 attribute。這也導(dǎo)致了不一致性,并要求用戶在非常常見的用例中手動強制布爾值為字符串,例如 aria-* attribute 像 aria-selected,aria-hidden,等等。

#3.x 語法

我們打算放棄“枚舉 attribute”的內(nèi)部概念,并將它們視為普通的非布爾 HTML attribute。

  • 這解決了普通非布爾 attribute 和“枚舉 attribute”之間的不一致性
  • 它還可以使用 'true''false' 以外的值,甚至可以使用 contenteditable 等 attribute 的關(guān)鍵字`

對于非布爾 attribute,如果 attribute 為 false,Vue 將停止刪除它們,相反強制它們?yōu)?'false'。

  • 這解決了 truefalse 之間的不一致性,并使輸出 aria-* attributes 更容易

下表描述了新行為:

綁定表達(dá)式 foo 正常 draggable 枚舉
:attr="null"// ?
:attr="undefined"//
:attr="true"foo="true"draggable="true"
:attr="false"foo="false" ?draggable="false"
:attr="0"foo="0"draggable="0" ?
attr=""foo=""draggable="" ?
attr="foo"foo="foo"draggable="foo" ?
attrfoo=""draggable="" ?

?: 變更

布爾 attributes 的強制保持不變。

#遷移策略

#枚舉 attribute

缺少枚舉 attribute 和 attr="false" 可能會產(chǎn)生不同的 IDL attribute 值 (將反映實際狀態(tài)),描述如下:

缺少枚舉attr IDL attr & 值
contenteditablecontentEditable → 'inherit'
draggabledraggable → false
spellcheckspellcheck → true

為了保持原有的行為,并且我們將強制使用 false'false',在 3.x Vue 中,開發(fā)人員需要將 v-bind 表達(dá)式解析為 false'false',表示 contenteditablespellcheck

在 2.x 中,枚舉 attribute 的無效值被強制為 'true'。這通常是無意的,不太可能大規(guī)模依賴。在 3.x 中,應(yīng)顯式指定 true'true'

#將 false 強制為 'false' 而不是刪除 attribute

在 3.x,nullundefined 應(yīng)用于顯式刪除 attribute。

#2.x 和 3.x 行為的比較

Attributes v-bind value 2.x v-bind value 3.x HTML 輸出
2.x “枚舉attribute” i.e. contenteditabledraggable and spellcheck.undefinedfalseundefinednullremoved
true'true'''1'foo'true'true'"true"
null'false'false'false'"false"
其他非布爾attribute eg. aria-checkedtabindexalt, etc.undefinednullfalseundefinednullremoved
'false'false'false'"false"

網(wǎng)頁題目:創(chuàng)新互聯(lián)VUE3教程:Vue3.0attribute強制行為
文章分享:http://uogjgqi.cn/article/dhhhgps.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流