Skip to content

如何动态的控制一个按钮的禁用和启用(控制disabled属性) #2423

@satrong

Description

@satrong

<button disabled="disabled"></button>
如果需要禁用一个button只需要加上disabled属性,需要启用就需要删除disabled属性。
请问除了用原生的方法删除属性,在vuejs中有没有相应的方法?

我用Knockoutjs的时候它有专门处理disabled的方法,不知vuejs有没有。

目前想到的一个方法是:

<button v-show="!disabled" disabled="disabled"></button>
<button v-show="disabled"></button>

如果button或者input多了,就有点繁琐了

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions