掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
信息

大悟網(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é):
false。相反,它被設(shè)置為 attr=“false”。移除 attribute,使用 null 或者 undefined。如需更深入的解釋,請繼續(xù)閱讀!
在 2.x,我們有以下策略來強制 v-bind 的值:
value 的 ,,``,等等。falsy 的,Vue 會移除它們 (undefined,null or false) 另外加上它們 (見這里和這里)。contenteditable,draggable 和 spellcheck),Vue 會嘗試強制將它們串起來 (目前對 contenteditable 做了特殊處理,修復(fù) vuejs/vue#9397)。falsy 值 (undefined,null,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" |
attr | foo="" | draggable="true" |
從上表可以看出,當(dāng)前實現(xiàn) true 強制為 'true' 但如果 attribute 為 false,則移除該 attribute。這也導(dǎo)致了不一致性,并要求用戶在非常常見的用例中手動強制布爾值為字符串,例如 aria-* attribute 像 aria-selected,aria-hidden,等等。
我們打算放棄“枚舉 attribute”的內(nèi)部概念,并將它們視為普通的非布爾 HTML attribute。
'true' 和 'false' 以外的值,甚至可以使用 contenteditable 等 attribute 的關(guān)鍵字` 對于非布爾 attribute,如果 attribute 為 false,Vue 將停止刪除它們,相反強制它們?yōu)?'false'。
true 和 false 之間的不一致性,并使輸出 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" ? |
attr | foo="" | draggable="" ? |
?: 變更
布爾 attributes 的強制保持不變。
缺少枚舉 attribute 和 attr="false" 可能會產(chǎn)生不同的 IDL attribute 值 (將反映實際狀態(tài)),描述如下:
| 缺少枚舉attr | IDL attr & 值 |
|---|---|
contenteditable | contentEditable → 'inherit' |
draggable | draggable → false |
spellcheck | spellcheck → true |
為了保持原有的行為,并且我們將強制使用 false 為 'false',在 3.x Vue 中,開發(fā)人員需要將 v-bind 表達(dá)式解析為 false 或 'false',表示 contenteditable 和 spellcheck。
在 2.x 中,枚舉 attribute 的無效值被強制為 'true'。這通常是無意的,不太可能大規(guī)模依賴。在 3.x 中,應(yīng)顯式指定 true 或 'true'。
false 強制為 'false' 而不是刪除 attribute 在 3.x,null 或 undefined 應(yīng)用于顯式刪除 attribute。
| Attributes | v-bind value 2.x |
v-bind value 3.x |
HTML 輸出 |
|---|---|---|---|
2.x “枚舉attribute” i.e. contenteditable, draggable and spellcheck. | undefined, false | undefined, null | removed |
true, 'true', '', 1, 'foo' | true, 'true' | "true" | |
null, 'false' | false, 'false' | "false" | |
其他非布爾attribute eg. aria-checked, tabindex, alt, etc. | undefined, null, false | undefined, null | removed |
'false' | false, 'false' | "false" |

我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流