Skip to content

Commit 55d485f

Browse files
committed
完善可配置项
1 parent dc03a91 commit 55d485f

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

.idea/workspace.xml

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/command-component/cmd-cmt.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,20 @@ define([''], function (){
8282
if (items[i].type === 'action') {
8383
var a = document.createElement('a'),
8484
className = items[i].className ? items[i].className : '';
85-
items[i].disabled && (className += 'disabled');
86-
a.href='#';
85+
if (items[i].disabled) {//li添加disabled的class,且让a标签失效(去掉其href)
86+
className += 'disabled';
87+
a.href = '#';
88+
} else {
89+
a.href = items[i].url ? items[i].url : '#';
90+
items[i].target && (a.target = items[i].target);
91+
}
8792
a.innerHTML = items[i].label;
8893
li.className = className;
89-
li.onclick = (function (i) {
94+
items[i].click && (li.onclick = (function (i) {
9095
return function (e) {
9196
items[i].click.call(this, e);
9297
}
93-
})(i);
98+
})(i));
9499
li.append(a);
95100
} else if (items[i].type === 'divider') {
96101
li.role = 'separator';

src/framework.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ define(['src/command-component/cmd-cmt'], function (cc) {
5050
label: 'action1',
5151
className: '',
5252
disabled: true,
53+
url: 'www.baidu.com',
54+
target: '_self',
5355
click: function (e) {
5456
console.log(1);
5557
}
@@ -65,6 +67,8 @@ define(['src/command-component/cmd-cmt'], function (cc) {
6567
},{
6668
type: 'action',
6769
label: 'action3',
70+
url: 'www.taobao.com',
71+
target: '_blank',
6872
click: function (e) {
6973
console.log(3);
7074
}

0 commit comments

Comments
 (0)