容易被误解的disabled

简介: 容易被误解的disabled

    1 <input disabled />
    <hr />
    2 <input disabled="true" />
    <hr />
    3 <input disabled="false" />
    <hr />
    4 <input :disabled="true" />
    <hr />
    5 <input :disabled="false" />

猜一猜这5个input输入框,哪些禁用了?

正确答案如下图:

1,2,3,4 都禁用了,只有 5 没有禁用,你猜对了吗?

下面我们来一个个分析

1 <input disabled />

最最原生的html写法,通过添加 disabled 属性来禁用input输入框,此时input输入框的 disabled 属性值为true

2 <input disabled="true" />

此处disabled 属性值为字符串 “true” ,转换为布尔值后为 true,所以也是禁用的。

3 <input disabled="false" />

此处disabled 属性值为字符串 “false” ,转换为布尔值后还是 true,所以也是禁用的。

4 <input :disabled="true" />

: 为vue中v-bind指令的简写,表示将布尔值 true 赋值给 disabled 属性,所以禁用生效。

5 <input :disabled="false" />

此处为将布尔值 false 赋值给 disabled 属性,所以禁用无效!

明白了吧,-_^ !

目录
相关文章
|
8月前
|
Docker Windows 容器
Containers feature is disabled. Enable it using the PowerShell script (in an administrative PowerShe
Containers feature is disabled. Enable it using the PowerShell script (in an administrative PowerShe
77 0
|
11月前
|
算法 安全 UED
Radio Link Monitoring(RLM)
这篇看下radio link monitoring相关的内容,就是UE进行DL radio link quality监听的规定,这部分与RLF的判定息息相关。市面上讲NR相关的书籍,多少都会涉及这部分内容,可能spec上这块的描述也比较好理解,书上也往往几行描述就结束了,但是还是值得研究下相关内容,接下来就看下spec中的描述。
disabled与readonly的区别
disabled与readonly的区别
34 0
configure: error: SELinux selected but libselinux not found
configure: error: SELinux selected but libselinux not found
88 0
error: exception handling disabled, use -fexceptions to enable
error: exception handling disabled, use -fexceptions to enable
55 0
ACTIVE控件Safe问题
ACTIVE控件Safe问题
59 0
|
数据安全/隐私保护
Development cannot be enabled while your device is locked.
有时候我们真机调试的时候,会遇到这样的报错: Development cannot be enabled while your device is locked. 但是!我TM手机明明解锁了啊,指纹解的锁不是?密码解的锁不是?没感应到?换个姿势再来一次?还是不行?? 哈哈,有同样经历的点个赞吧。
1860 0