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
645cc085
Commit
645cc085
authored
Aug 23, 2016
by
baiyaaaaa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tab events
parent
e113f469
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
23 deletions
+17
-23
examples/docs/tabs.md
examples/docs/tabs.md
+5
-5
packages/tabs/src/tabs.vue
packages/tabs/src/tabs.vue
+11
-17
packages/theme-default/src/tabs.css
packages/theme-default/src/tabs.css
+1
-1
No files found.
examples/docs/tabs.md
View file @
645cc085
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
## 基础使用
## 基础使用
<div>
<div>
<el-tabs>
<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>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
...
@@ -78,7 +78,7 @@
...
@@ -78,7 +78,7 @@
## 可关闭的标签
## 可关闭的标签
<div>
<div>
<el-tabs
type=
"card"
:closable=
"true"
:on-remove=
"handleRemove"
:on
-click=
"handleClick"
>
<el-tabs
type=
"card"
:closable=
"true"
@
tab-remove=
"handleRemove"
@
tab
-click=
"handleClick"
>
<el-tab-pane
label=
"选项卡一"
>
选项卡一内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡一"
>
选项卡一内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
{{activeName2}}
{{activeName2}}
```
html
```
html
<el-tabs
type=
"card"
:closable=
"true"
:on-remove=
"handleRemove"
:on
-click=
"handleClick"
>
<el-tabs
type=
"card"
:closable=
"true"
@
tab-remove=
"handleRemove"
@
tab
-click=
"handleClick"
>
<el-tab-pane
label=
"选项卡一"
>
选项卡一内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡一"
>
选项卡一内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡二"
>
选项卡二内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
<el-tab-pane
label=
"选项卡三"
>
选项卡三内容
</el-tab-pane>
...
@@ -122,8 +122,8 @@
...
@@ -122,8 +122,8 @@
| type | 风格类型 | string | card, border-card | |
| type | 风格类型 | string | card, border-card | |
| closable | 真实值 | boolean | true, false | false |
| closable | 真实值 | boolean | true, false | false |
| activeName | 当前选中面板的 name | string | | |
| activeName | 当前选中面板的 name | string | | |
|
on
-click | tab 被点击的钩子 | string | | |
|
tab
-click | tab 被点击的钩子 | string | | |
|
on
-remove | tab 被删除的钩子 | string | | |
|
tab
-remove | tab 被删除的钩子 | string | | |
## TAB-PANE API
## TAB-PANE API
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
...
...
packages/tabs/src/tabs.vue
View file @
645cc085
<
script
>
<
script
>
import
ElTab
from
'
./tab
'
;
import
ElTab
from
'
./tab
'
;
function
noop
()
{}
module
.
exports
=
{
module
.
exports
=
{
name
:
'
el-tabs
'
,
name
:
'
el-tabs
'
,
...
@@ -15,14 +13,6 @@
...
@@ -15,14 +13,6 @@
tabPosition
:
String
,
tabPosition
:
String
,
activeName
:
String
,
activeName
:
String
,
closable
:
false
,
closable
:
false
,
onRemove
:
{
type
:
Function
,
default
:
noop
},
onClick
:
{
type
:
Function
,
default
:
noop
},
tabWidth
:
0
tabWidth
:
0
},
},
...
@@ -39,7 +29,8 @@
...
@@ -39,7 +29,8 @@
watch
:
{
watch
:
{
activeName
:
{
activeName
:
{
handler
(
val
)
{
handler
(
val
)
{
this
.
currentName
=
val
||
this
.
$children
[
0
].
key
;
var
fisrtKey
=
this
.
$children
[
0
]
&&
this
.
$children
[
0
].
key
||
'
1
'
;
this
.
currentName
=
val
||
fisrtKey
;
}
}
},
},
...
@@ -66,13 +57,13 @@
...
@@ -66,13 +57,13 @@
this
.
currentName
=
nextChild
?
nextChild
.
key
:
prevChild
?
prevChild
.
key
:
'
-1
'
;
this
.
currentName
=
nextChild
?
nextChild
.
key
:
prevChild
?
prevChild
.
key
:
'
-1
'
;
}
}
this
.
onRemove
(
tab
.
key
);
this
.
$emit
(
'
tab-remove
'
,
tab
.
key
);
},
},
handleTabClick
(
tab
,
event
)
{
handleTabClick
(
tab
,
event
)
{
this
.
currentName
=
tab
.
key
;
this
.
currentName
=
tab
.
key
;
this
.
onClick
(
tab
.
key
,
event
);
this
.
$emit
(
'
tab-click
'
,
tab
.
key
,
event
);
},
},
calcBarStyle
()
{
calcBarStyle
(
firstRendering
)
{
if
(
this
.
type
||
!
this
.
$refs
.
tabs
)
return
{};
if
(
this
.
type
||
!
this
.
$refs
.
tabs
)
return
{};
var
style
=
{};
var
style
=
{};
var
offset
=
0
;
var
offset
=
0
;
...
@@ -92,16 +83,19 @@
...
@@ -92,16 +83,19 @@
style
.
width
=
tabWidth
+
'
px
'
;
style
.
width
=
tabWidth
+
'
px
'
;
style
.
transform
=
`translateX(
${
offset
}
px)`
;
style
.
transform
=
`translateX(
${
offset
}
px)`
;
if
(
!
firstRendering
)
{
style
.
transition
=
'
transform .3s cubic-bezier(.645,.045,.355,1), -webkit-transform .3s cubic-bezier(.645,.045,.355,1)
'
;
}
this
.
barStyle
=
style
;
this
.
barStyle
=
style
;
}
}
},
},
mounted
()
{
mounted
()
{
if
(
!
this
.
currentName
)
{
if
(
!
this
.
currentName
)
{
this
.
currentName
=
this
.
$children
[
0
].
key
;
var
fisrtKey
=
this
.
$children
[
0
]
&&
this
.
$children
[
0
].
key
||
'
1
'
;
this
.
currentName
=
this
.
activeName
||
fisrtKey
;
}
}
this
.
$children
.
forEach
(
tab
=>
this
.
tabs
.
push
(
tab
));
this
.
$children
.
forEach
(
tab
=>
this
.
tabs
.
push
(
tab
));
this
.
$nextTick
(()
=>
this
.
calcBarStyle
());
this
.
$nextTick
(()
=>
this
.
calcBarStyle
(
true
));
}
}
};
};
</
script
>
</
script
>
...
...
packages/theme-default/src/tabs.css
View file @
645cc085
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
height
:
3px
;
height
:
3px
;
background-color
:
var
(
--color-primary
);
background-color
:
var
(
--color-primary
);
z-index
:
1
;
z-index
:
1
;
transition
:
transform
.3s
cubic-bezier
(
.645
,
.045
,
.355
,
1
);
/*transition: transform .3s cubic-bezier(.645,.045,.355,1);*/
list-style
:
none
;
list-style
:
none
;
}
}
@e
item
{
@e
item
{
...
...
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