This repository has been archived by the owner on Dec 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<page header-title="Switch 开关"> | ||
<panel | ||
title="基础用法" | ||
no-padding | ||
> | ||
<example-item> | ||
<at-switch | ||
title="开启中" | ||
checked | ||
/> | ||
<at-switch | ||
title="已关闭" | ||
border | ||
/> | ||
</example-item> | ||
</panel> | ||
|
||
<panel | ||
title="使用 v-model 或 onChange 获取开关状态" | ||
no-padding | ||
> | ||
<example-item> | ||
<at-switch | ||
:title="`绑定 checked + onChange:${' '.repeat(6)}${switchValue ? '开启中' : '已关闭'}`" | ||
:checked="switchValue" | ||
@change="handleChange" | ||
/> | ||
<at-switch | ||
:title="`使用 v-model:checked:${' '.repeat(13)}${switchValue2 ? '开启中' : '已关闭'}`" | ||
v-model:checked="switchValue2" | ||
border | ||
/> | ||
</example-item> | ||
</panel> | ||
|
||
<panel | ||
title="禁用状态" | ||
no-padding | ||
> | ||
<example-item> | ||
<at-switch | ||
title="不可点击: 无 border" | ||
checked | ||
disabled | ||
/> | ||
<at-switch | ||
title="不可点击: 有 border" | ||
border | ||
disabled | ||
/> | ||
</example-item> | ||
</panel> | ||
</page> | ||
|
||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref } from 'vue' | ||
import { AtSwitch } from '../../../index' | ||
import { Page, Panel, ExampleItem } from '../../components/demo-page' | ||
import './index.scss' | ||
export default defineComponent({ | ||
name: "SwitchDemo", | ||
components: { | ||
AtSwitch, | ||
Page, | ||
Panel, | ||
ExampleItem | ||
}, | ||
setup() { | ||
const switchValue = ref(true) | ||
const switchValue2 = ref(true) | ||
const handleChange = (value: boolean): void => { | ||
switchValue.value = value | ||
} | ||
return { | ||
switchValue, | ||
switchValue2, | ||
handleChange | ||
} | ||
} | ||
}) | ||
</script> |