Instructions for using button components in WeChat mini programs

亚连
Release: 2018-06-08 16:42:29
Original
2724 people have browsed it

This article mainly introduces the use of the WeChat applet button component in detail. It has certain reference value. Interested friends can refer to it.

This article shares the WeChat applet button with everyone. How to use the component is for your reference. The specific content is as follows

Display rendering

Instructions for using button components in WeChat mini programs

Common attributes of button component

  • size: default, mini—default is a block-level button, mini is a small button

  • type: primary, default, warn—primary is submitted successfully, default is gray, warn Warning color

  • plain: true, false—whether the button is hollow and the background color is transparent

  • ##disabled: true, false—whether it is disabled

  • loading: true, false—whether there is a loading icon before the name

  • ##WXML
                   
Copy after login

WXSS

.tui-btn-group{ padding: 10px; } .tui-btn-content{ height: 60px; line-height: 60px; } /** 修改button默认的点击态样式类**/ .button-hover { background-color: red; } /** 添加自定义button点击态样式类**/ .other-button-hover { background-color: blue; }
Copy after login

JS

var types = ['default', 'primary', 'warn'] var pageObject = { data: { defaultSize: 'default', primarySize: 'default', warnSize: 'default', disabled: false, plain: false, loading: false }, setDisabled: function (e) { this.setData({ disabled: !this.data.disabled }) }, setPlain: function (e) { this.setData({ plain: !this.data.plain }) }, setLoading: function (e) { this.setData({ loading: !this.data.loading }) } } //循环给'default', 'primary', 'warn'按钮创建函数 for (var i = 0; i < types.length; ++i) { (function (type) { pageObject[type] = function (e) { var key = type + 'Size' var changedData = {} changedData[key] = this.data[key] === 'default' ? 'mini' : 'default' this.setData(changedData) } })(types[i]) } Page(pageObject);
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

What are the differences between let and var defining variables in js?

Nuxt.js Vue server-side rendering exploration

VUE personal summary (problems encountered)

The above is the detailed content of Instructions for using button components in WeChat mini programs. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!