按钮 / Button Star

按钮

普通青年

test
1
2
3
4
5
6
require(['jquery', 'ui/Button'], function ($, Button) {
new Button({
main: document.getElementById('button1')
})
.render();
});

参数配置

configuration
1
2
3
4
5
6
7
8
9
require(['jquery', 'ui/Button'], function ($, Button) {
new Button({
main: document.getElementById('button2'),
width: '100px',
height: '61.8px',
text: 'hello world~'
})
.render();
});

事件绑定

event-binding
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require(['jquery', 'ui/Button'], function ($, Button) {

var i = 0;

new Button({
main: document.getElementById('button3'),
text: '赞'
})
.render()
.on('click', function (e) {
this.setText('+' + (++i));
});

});

应用于<a>标签

link
1
2
3
4
5
6
7
8
require(['jquery', 'ui/Button'], function ($, Button) {

new Button({
main: document.getElementById('button4')
})
.render();

});

禁用状态

disable
1
2
3
4
5
6
7
8
9
10
11
12
require(['jquery', 'ui/Button'], function ($, Button) {

new Button({
main: document.getElementById('button5'),
disabled: true
})
.render()
.on('click', function () {
console.log('如果这里被调用就出错了哟~');
});

});