Foreword: I didn’t read the official documents of uniapp carefullyuniapp, so I was thinking about creating a click event, putting a timer, etc. .
Later, when I looked at the official documents, I found that they have the attribute hover-class, as follows:
attribute name | type | default value | illustrate |
---|---|---|---|
hover-class | String | none | Specify the style class to press. When hover-class="none", there is no click state effect |
hover-stop-propagation | Boolean | false | Specifies whether to prevent the ancestor nodes of this node from being clicked. |
hover-start-time | Number | 50 | How long does it take for the click state to appear after pressing and holding, in milliseconds |
hover-stay-time | Number | 400 | The click state retention time after the finger is released, in milliseconds |
Therefore, you only need to add the attribute to the required view tag: hover-class="bg-click"
.bg-click{
background:#fafafa;
}