Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
eb601266
Commit
eb601266
authored
Aug 12, 2016
by
qingwei.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tabs
build entry.js index => name fix tab doc
parent
d607187d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
85 deletions
+94
-85
bin/build-entry.js
bin/build-entry.js
+6
-6
components.json
components.json
+0
-3
examples/docs/tabs.md
examples/docs/tabs.md
+8
-8
packages/tabs/src/tab-pane.vue
packages/tabs/src/tab-pane.vue
+11
-9
packages/tabs/src/tab.vue
packages/tabs/src/tab.vue
+14
-11
packages/tabs/src/tabs.vue
packages/tabs/src/tabs.vue
+53
-43
src/index.js
src/index.js
+2
-5
No files found.
bin/build-entry.js
View file @
eb601266
...
...
@@ -14,13 +14,13 @@ const install = function(Vue) {
{{install}}
//
Vue.use(Loading);
Vue.use(Loading);
//
Vue.prototype.$msgbox = MessageBox;
//
Vue.prototype.$alert = MessageBox.alert;
//
Vue.prototype.$confirm = MessageBox.confirm;
//
Vue.prototype.$prompt = MessageBox.prompt;
//
Vue.prototype.$notify = Notification;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
};
// auto install
...
...
components.json
View file @
eb601266
{
"group"
:
[
"./packages/group/index.js"
],
"select-dropdown"
:
[
"./packages/select-dropdown/index.js"
],
...
...
examples/docs/tabs.md
View file @
eb601266
...
...
@@ -15,8 +15,8 @@
title: '选项卡四',
content: '选项卡四内容'
}],
active
Key
: '3',
active
Key
2: ''
active
Name
: '3',
active
Name
2: ''
}
}
}
...
...
@@ -30,7 +30,7 @@
## 基础使用
<div>
<el-tabs
:active-
key=
"activeKey
"
>
<el-tabs
:active-
name=
"activeName
"
>
<el-tab-pane
label=
"选项卡一"
>
选项卡一内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
...
...
@@ -39,7 +39,7 @@
</div>
```
html
<el-tabs
:active-
key=
"activeKey
"
>
<el-tabs
:active-
name=
"activeName
"
>
<el-tab-pane
label=
"选项卡一"
>
选项卡一内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
...
...
@@ -77,7 +77,7 @@
<el-tab-pane
label=
"选项卡四"
>
选项卡四内容
</el-tab-pane>
</el-tabs>
</div>
{{active
Key
2}}
{{active
Name
2}}
```
html
<el-tabs
type=
"card"
:closable=
"true"
>
...
...
@@ -113,8 +113,8 @@
|---------- |-------- |---------- |------------- |-------- |
| type | 风格类型 | string | card, border-card | |
| closable | 真实值 | boolean | true, false | false |
| defaultActive
Key | 如果没有设置 activeKey
, 则使用该值 | string | | 第一个面板 |
| active
Key | 当前选中面板的key
| string | | |
| defaultActive
Name | 如果没有设置 activeName
, 则使用该值 | string | | 第一个面板 |
| active
Name | 当前选中面板的 name
| string | | |
| tab.click | tab 被点击的回调 | string | | |
| tab.remove | tab 被删除的回调 | string | | |
...
...
@@ -122,4 +122,4 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| label | 选项卡标题 | string | | |
|
key | 与选项卡activeKey对应的标识符 | string | | 该选项卡在选项卡中的index
值,如第一个选项卡则为'1' |
|
name | 与选项卡 activeName 对应的标识符 | string | | 该选项卡在选项卡中的 name
值,如第一个选项卡则为'1' |
packages/tabs/src/tab-pane.vue
View file @
eb601266
...
...
@@ -7,9 +7,7 @@
type
:
String
,
required
:
true
},
key
:
{
type
:
String
}
name
:
String
},
data
()
{
...
...
@@ -18,7 +16,8 @@
transition
:
''
,
paneStyle
:
{
position
:
'
relative
'
}
},
key
:
''
};
},
...
...
@@ -28,17 +27,20 @@
}
},
events
:
{
},
computed
:
{
show
()
{
return
this
.
$parent
.
activeKey
===
this
.
key
;
return
this
.
$parent
.
currentName
===
this
.
key
;
}
},
watch
:
{
'
$parent.activeKey
'
(
newValue
,
oldValue
)
{
name
:
{
immediate
:
true
,
handler
(
val
)
{
this
.
key
=
val
;
}
},
'
$parent.currentName
'
(
newValue
,
oldValue
)
{
if
(
this
.
key
===
newValue
)
{
this
.
transition
=
newValue
>
oldValue
?
'
slideInRight
'
:
'
slideInLeft
'
;
}
...
...
packages/tabs/src/tab.vue
View file @
eb601266
...
...
@@ -8,20 +8,23 @@
required
:
true
},
closable
:
Boolean
},
data
()
{
return
{
showClose
:
false
};
}
};
</
script
>
<
template
>
<div
class=
"el-tabs__item"
:class=
"
{
'is-active': $parent.activeKey === tab.key,
'is-disabled': tab.disabled,
'is-closable': closable
}">
{{
tab
.
label
}}
<span
class=
"el-icon-close"
v-if=
"closable"
@
click=
"$emit('onremove', tab, $event)"
></span></div>
<div
class=
"el-tabs__item"
:class=
"
{
'is-active': $parent.currentName === tab.key,
'is-disabled': tab.disabled,
'is-closable': closable
}">
{{
tab
.
label
}}
<span
class=
"el-icon-close"
v-if=
"closable"
@
click=
"$emit('onremove', tab, $event)"
>
</span>
</div>
</
template
>
packages/tabs/src/tabs.vue
View file @
eb601266
...
...
@@ -11,12 +11,8 @@
props
:
{
type
:
String
,
tabPosition
:
String
,
defaultActiveKey
:
{
type
:
String
},
activeKey
:
{
type
:
String
},
defaultActiveName
:
String
,
activeName
:
String
,
closable
:
false
,
tabWidth
:
0
},
...
...
@@ -25,34 +21,22 @@
return
{
tabs
:
[],
children
:
null
,
activeTab
:
null
activeTab
:
null
,
currentName
:
0
,
barStyle
:
''
};
},
computed
:
{
barStyle
:
{
cache
:
false
,
get
()
{
if
(
this
.
type
)
return
{};
var
style
=
{};
var
offset
=
0
;
var
tabWidth
=
0
;
this
.
tabs
.
every
((
tab
,
index
)
=>
{
let
$el
=
this
.
$refs
.
tabs
[
index
].
$el
;
if
(
tab
.
key
!==
this
.
activeKey
)
{
offset
+=
$el
.
clientWidth
;
return
true
;
}
else
{
tabWidth
=
$el
.
clientWidth
;
return
false
;
}
});
style
.
width
=
tabWidth
+
'
px
'
;
style
.
transform
=
`translateX(
${
offset
}
px)`
;
return
style
;
watch
:
{
activeName
:
{
immediate
:
true
,
handler
(
val
)
{
this
.
currentName
=
val
||
0
;
}
},
'
currentName
'
()
{
this
.
calcBarStyle
();
}
},
...
...
@@ -67,27 +51,49 @@
this
.
tabs
.
splice
(
index
,
1
);
}
if
(
tab
.
key
===
this
.
activeKey
)
{
if
(
tab
.
key
===
this
.
currentName
)
{
let
deleteIndex
=
this
.
$children
.
indexOf
(
tab
);
let
nextChild
=
this
.
$children
[
deleteIndex
+
1
];
let
prevChild
=
this
.
$children
[
deleteIndex
-
1
];
this
.
activeKey
=
nextChild
?
nextChild
.
key
:
prevChild
?
prevChild
.
key
:
'
-1
'
;
this
.
currentName
=
nextChild
?
nextChild
.
key
:
prevChild
?
prevChild
.
key
:
'
-1
'
;
}
this
.
$emit
(
'
tab.remove
'
,
tab
);
},
handleTabClick
(
tab
)
{
this
.
activeKey
=
tab
.
key
;
this
.
currentName
=
tab
.
key
;
this
.
$emit
(
'
tab.click
'
,
tab
);
},
calcBarStyle
()
{
if
(
this
.
type
)
return
{};
var
style
=
{};
var
offset
=
0
;
var
tabWidth
=
0
;
this
.
tabs
.
every
((
tab
,
index
)
=>
{
let
$el
=
this
.
$refs
.
tabs
[
index
].
$el
;
if
(
tab
.
key
!==
this
.
currentName
)
{
offset
+=
$el
.
clientWidth
;
return
true
;
}
else
{
tabWidth
=
$el
.
clientWidth
;
return
false
;
}
});
style
.
width
=
tabWidth
+
'
px
'
;
style
.
transform
=
`translateX(
${
offset
}
px)`
;
this
.
barStyle
=
style
;
}
},
ready
()
{
if
(
!
this
.
activeKey
)
{
this
.
activeKey
=
this
.
defaultActiveKey
||
this
.
$children
[
0
].
key
;
mounted
()
{
if
(
!
this
.
currentName
)
{
this
.
currentName
=
this
.
defaultActiveName
||
this
.
$children
[
0
].
key
;
}
this
.
$children
.
forEach
(
tab
=>
{
this
.
tabs
.
push
(
tab
);
});
this
.
$children
.
forEach
(
tab
=>
this
.
tabs
.
push
(
tab
));
this
.
$nextTick
(()
=>
this
.
calcBarStyle
());
}
};
</
script
>
...
...
@@ -97,13 +103,17 @@
<div
class=
"el-tabs__header"
>
<el-tab
v-for=
"tab in tabs"
v-ref:tabs
ref=
"tabs"
:tab=
"tab"
:closable=
"closable"
@
onremove=
"removeTab"
@
click=
"handleTabClick(tab)"
></el-tab>
<div
class=
"el-tabs__active-bar"
v-bind:style=
"barStyle"
v-if=
"!this.type && tabs.length > 0"
></div>
@
click.native=
"handleTabClick(tab)"
>
</el-tab>
<div
class=
"el-tabs__active-bar"
:style=
"barStyle"
v-if=
"!this.type && tabs.length > 0"
>
</div>
</div>
<div
class=
"el-tabs__content"
>
...
...
src/index.js
View file @
eb601266
import
Group
from
'
../packages/group/index.js
'
;
import
SelectDropdown
from
'
../packages/select-dropdown/index.js
'
;
import
Pagination
from
'
../packages/pagination/index.js
'
;
import
Dialog
from
'
../packages/dialog/index.js
'
;
...
...
@@ -52,7 +51,6 @@ import Spinner from '../packages/spinner/index.js';
const
install
=
function
(
Vue
)
{
if
(
install
.
installed
)
return
;
Vue
.
component
(
Group
.
name
,
Group
);
Vue
.
component
(
SelectDropdown
.
name
,
SelectDropdown
);
Vue
.
component
(
Pagination
.
name
,
Pagination
);
Vue
.
component
(
Dialog
.
name
,
Dialog
);
...
...
@@ -109,14 +107,13 @@ const install = function(Vue) {
Vue
.
prototype
.
$notify
=
Notification
;
};
auto
install
//
auto install
if
(
typeof
window
!==
'
undefined
'
&&
window
.
Vue
)
{
install
(
window
.
Vue
);
};
module
.
exports
=
{
install
Group
,
install
,
SelectDropdown
,
Pagination
,
Dialog
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment