2021-12-30 00:44:43 +08:00
|
|
|
::: anchor
|
|
|
|
:::
|
|
|
|
|
2022-02-06 05:20:07 +08:00
|
|
|
::: title 基本介绍
|
|
|
|
:::
|
|
|
|
|
|
|
|
::: describe 提供平级的区域将大块内容进行收纳和展现,保持界面整洁。
|
|
|
|
:::
|
|
|
|
|
2021-10-26 01:13:23 +08:00
|
|
|
::: title 基础使用
|
2021-10-19 22:28:44 +08:00
|
|
|
:::
|
|
|
|
|
2021-10-05 19:04:06 +08:00
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
2021-10-13 02:32:29 +08:00
|
|
|
<lay-tab v-model="current1">
|
2021-10-08 19:57:03 +08:00
|
|
|
<lay-tab-item title="选项一" id="1"><div style="padding:20px">选项一</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项二" id="2"><div style="padding:20px">选项二</div></lay-tab-item>
|
|
|
|
</lay-tab>
|
2021-10-08 17:32:05 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
2021-10-13 02:32:29 +08:00
|
|
|
const current1 = ref("1")
|
2021-10-08 19:57:03 +08:00
|
|
|
|
2021-10-08 17:32:05 +08:00
|
|
|
return {
|
2021-10-13 02:32:29 +08:00
|
|
|
current1
|
2021-10-08 17:32:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2021-10-26 01:13:23 +08:00
|
|
|
::: title 简约模式
|
2021-10-19 22:28:44 +08:00
|
|
|
:::
|
|
|
|
|
2021-10-08 17:32:05 +08:00
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
2021-10-08 19:57:03 +08:00
|
|
|
<lay-tab type="brief" v-model="current2">
|
|
|
|
<lay-tab-item title="选项一" id="1"><div style="padding:20px">选项一</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项二" id="2"><div style="padding:20px">选项二</div></lay-tab-item>
|
|
|
|
</lay-tab>
|
2021-10-08 17:32:05 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
2021-10-08 19:57:03 +08:00
|
|
|
const current2 = ref("1")
|
|
|
|
|
2021-10-08 17:32:05 +08:00
|
|
|
return {
|
2021-10-08 19:57:03 +08:00
|
|
|
current2
|
2021-10-08 17:32:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2021-10-26 01:13:23 +08:00
|
|
|
::: title 卡片模式
|
2021-10-19 22:28:44 +08:00
|
|
|
:::
|
|
|
|
|
2021-10-08 17:32:05 +08:00
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
2021-10-08 19:57:03 +08:00
|
|
|
<lay-tab type="card" v-model="current3">
|
|
|
|
<lay-tab-item title="选项一" id="1"><div style="padding:20px">选项一</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项二" id="2"><div style="padding:20px">选项二</div></lay-tab-item>
|
|
|
|
</lay-tab>
|
2021-10-05 19:04:06 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
2021-10-08 19:57:03 +08:00
|
|
|
const current3 = ref("1")
|
|
|
|
|
2021-10-05 19:04:06 +08:00
|
|
|
return {
|
2021-10-08 19:57:03 +08:00
|
|
|
current3
|
2021-10-05 19:04:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-10-09 10:41:52 +08:00
|
|
|
:::
|
|
|
|
|
2021-10-26 01:13:23 +08:00
|
|
|
::: title 允许关闭
|
2021-10-19 22:28:44 +08:00
|
|
|
:::
|
|
|
|
|
2021-10-15 23:52:01 +08:00
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
2021-10-19 11:47:27 +08:00
|
|
|
<lay-tab type="card" v-model="current4" :allow-close="allowClose" @change="change" @close="close">
|
2021-10-15 23:52:01 +08:00
|
|
|
<lay-tab-item title="选项一" id="1"><div style="padding:20px">选项一</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项二" id="2"><div style="padding:20px">选项二</div></lay-tab-item>
|
2021-12-10 08:01:48 +08:00
|
|
|
<lay-tab-item title="选项三" id="3"><div style="padding:20px">选项三</div></lay-tab-item>
|
2021-10-15 23:52:01 +08:00
|
|
|
</lay-tab>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
|
|
|
const current4 = ref("1")
|
|
|
|
const allowClose = ref(true)
|
|
|
|
|
|
|
|
const change = function(id){
|
|
|
|
console.log("当前值:" +id)
|
|
|
|
}
|
|
|
|
|
|
|
|
const close = function(id){
|
2021-12-10 08:01:48 +08:00
|
|
|
console.log("当前关闭:" + id)
|
2021-10-15 23:52:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-10-19 11:47:27 +08:00
|
|
|
current4,
|
2021-10-15 23:52:01 +08:00
|
|
|
allowClose,
|
|
|
|
change,
|
|
|
|
close
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2021-10-13 02:32:29 +08:00
|
|
|
|
|
|
|
:::
|
|
|
|
|
2022-01-18 01:28:39 +08:00
|
|
|
::: title 关闭前置
|
2021-12-10 08:01:48 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<lay-tab type="card" v-model="current5" allow-close @change="change5" @close="close5" :beforeClose="beforeClose">
|
2022-01-18 01:28:39 +08:00
|
|
|
<lay-tab-item title="选项一" id="1" closable="true"><div style="padding:20px">选项一</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项二" id="2" closable="false"><div style="padding:20px">选项二</div></lay-tab-item>
|
2021-12-10 08:01:48 +08:00
|
|
|
<lay-tab-item title="选项三" id="3"><div style="padding:20px">选项三</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项四" id="4"><div style="padding:20px">选项四</div></lay-tab-item>
|
|
|
|
<lay-tab-item title="选项五" id="5"><div style="padding:20px">选项五</div></lay-tab-item>
|
|
|
|
</lay-tab>
|
|
|
|
<div style="color:#ff5722;">id为单数的可以关闭</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
|
|
|
const current5 = ref("1")
|
|
|
|
|
|
|
|
const change5 = function(id){
|
|
|
|
console.log("当前值:" +id)
|
|
|
|
}
|
|
|
|
|
|
|
|
const beforeClose = function(id){
|
|
|
|
return parseInt(id) % 2 === 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const close5 = function(id){
|
|
|
|
console.log("当前关闭:" + id)
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
current5,
|
|
|
|
change5,
|
2022-01-10 01:17:03 +08:00
|
|
|
beforeClose,
|
2021-12-10 08:01:48 +08:00
|
|
|
close5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2021-10-26 01:13:23 +08:00
|
|
|
::: title 嵌套循环
|
2021-10-19 22:28:44 +08:00
|
|
|
:::
|
2021-10-19 11:47:27 +08:00
|
|
|
|
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
2022-01-18 01:28:39 +08:00
|
|
|
<lay-tab type="card" allow-close v-model="current6" @change="change6">
|
|
|
|
<lay-tab-item v-for="a in arr" :key="a" :title="a.title" :id="a.id" :closable="a.closable">
|
2021-12-10 08:01:48 +08:00
|
|
|
内容{{a.id}}
|
2021-10-19 11:47:27 +08:00
|
|
|
</lay-tab-item>
|
|
|
|
</lay-tab>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
2021-12-10 08:01:48 +08:00
|
|
|
const current6 = ref('1')
|
|
|
|
const change6 = function(id){
|
2021-10-19 22:28:44 +08:00
|
|
|
alert(id)
|
|
|
|
}
|
2021-10-19 11:47:27 +08:00
|
|
|
|
2021-10-19 22:28:44 +08:00
|
|
|
const arr = ref([
|
2022-01-18 01:28:39 +08:00
|
|
|
{id:'1', title:'选项一', closable: false},
|
|
|
|
{id:'2', title:'选项二'},
|
|
|
|
{id:'3', title:'选项三'}
|
2021-10-19 22:28:44 +08:00
|
|
|
])
|
|
|
|
|
2021-10-19 11:47:27 +08:00
|
|
|
return {
|
2021-12-10 08:01:48 +08:00
|
|
|
current6,
|
2021-10-19 11:47:27 +08:00
|
|
|
arr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2022-01-10 01:17:03 +08:00
|
|
|
::: title Tab 属性
|
2021-10-15 23:52:01 +08:00
|
|
|
:::
|
2021-10-12 18:00:09 +08:00
|
|
|
|
2021-11-07 15:55:08 +08:00
|
|
|
::: table
|
|
|
|
|
2022-01-18 01:28:39 +08:00
|
|
|
| 属性 | 描述 | 可选值 |
|
|
|
|
| ------------ | ------------------------------------ | ----------------------------------------- |
|
|
|
|
| v-model | 当前激活 | -- |
|
|
|
|
| type | 主题样式 | -- |
|
|
|
|
| allow-close | 允许关闭 | `true` `false` |
|
|
|
|
| before-close | `Function`关闭之前的回调钩子函数 | 参数(`id`), `return false` 表示不进行关闭 |
|
|
|
|
| before-leave | `Function`切换标签之前的回调钩子函数 | 参数(`id`), `return false` 表示不进行切换 |
|
2021-10-15 23:52:01 +08:00
|
|
|
|
2021-11-07 15:55:08 +08:00
|
|
|
:::
|
|
|
|
|
2022-01-10 01:17:03 +08:00
|
|
|
::: title Tab 事件
|
2021-10-15 23:52:01 +08:00
|
|
|
:::
|
|
|
|
|
2021-11-07 15:55:08 +08:00
|
|
|
::: table
|
|
|
|
|
2021-11-01 01:02:21 +08:00
|
|
|
| 事件 | 描述 | 参数 |
|
|
|
|
| ------ | -------- | ---- |
|
2021-12-10 08:01:48 +08:00
|
|
|
| change | 选中切换 | id |
|
|
|
|
| close | 关闭事件 | id |
|
2021-11-07 15:55:08 +08:00
|
|
|
|
2021-11-07 15:56:24 +08:00
|
|
|
:::
|
2021-12-16 17:57:59 +08:00
|
|
|
|
2022-01-18 01:28:39 +08:00
|
|
|
::: title Tab Item 属性
|
|
|
|
:::
|
|
|
|
|
|
|
|
::: table
|
|
|
|
|
|
|
|
| 属性 | 描述 | 可选值 |
|
|
|
|
| -------- | -------- | ------ |
|
|
|
|
| id | 唯一标识 | -- |
|
|
|
|
| title | 头部标题 | -- |
|
|
|
|
| closable | 允许关闭 | -- |
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2021-12-16 17:57:59 +08:00
|
|
|
::: comment
|
2022-01-12 14:19:06 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
::: previousNext tab
|
2022-01-18 01:28:39 +08:00
|
|
|
:::
|