docs: 更新文档

This commit is contained in:
就眠仪式 2021-10-27 02:04:47 +08:00
parent 401efd527d
commit e6cd15ea05
11 changed files with 200 additions and 42 deletions

View File

@ -5,7 +5,7 @@
<template> <template>
<lay-dropdown> <lay-dropdown>
<lay-button>下拉菜单</lay-button> <lay-button type="primary">下拉菜单</lay-button>
<template #content> <template #content>
<lay-dropdown-item>选项一</lay-dropdown-item> <lay-dropdown-item>选项一</lay-dropdown-item>
<lay-dropdown-item>选项二</lay-dropdown-item> <lay-dropdown-item>选项二</lay-dropdown-item>

View File

@ -29,11 +29,11 @@ export default {
::: demo ::: demo
<template> <template>
<lay-progress percent="80" size="big"></lay-progress> <lay-progress percent="40" size="big"></lay-progress>
<br> <br>
<lay-progress percent="60" size="big" theme="orange"></lay-progress> <lay-progress percent="60" size="big" theme="green"></lay-progress>
<br> <br>
<lay-progress percent="60" size="big" theme="blue"></lay-progress> <lay-progress percent="80" size="big" theme="cyan"></lay-progress>
</template> </template>
<script> <script>
@ -50,6 +50,37 @@ export default {
::: :::
::: title 指定主题
:::
::: demo
<template>
<lay-progress percent="60" theme="red"></lay-progress>
<br>
<lay-progress percent="60" theme="orange"></lay-progress>
<br>
<lay-progress percent="60" theme="green"></lay-progress>
<br>
<lay-progress percent="60" theme="blue"></lay-progress>
<br>
<lay-progress percent="60" theme="cyan"></lay-progress>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
return {
}
}
}
</script>
:::
::: title 显示文字 ::: title 显示文字
::: :::

View File

@ -53,7 +53,7 @@ export default {
::: demo ::: demo
<template> <template>
<lay-rate v-model="all2" :length="length"></lay-rate> {{all2}} <lay-rate v-model="all2" :length="length"></lay-rate>
</template> </template>
<script> <script>
@ -75,6 +75,63 @@ export default {
::: :::
::: title 只读模式
:::
::: demo
<template>
<lay-rate v-model="all3" readonly="true"></lay-rate>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const all3 = ref(4)
return {
all3
}
}
}
</script>
:::
::: title 定义主题
:::
::: demo
<template>
<lay-rate v-model="all4" theme="#FF8000"></lay-rate><br>
<lay-rate v-model="all4" theme="#009688"></lay-rate><br>
<lay-rate v-model="all4" theme="#1E9FFF"></lay-rate><br>
<lay-rate v-model="all4" theme="#2F4056"></lay-rate><br>
<lay-rate v-model="all4" theme="#FE0000"></lay-rate><br>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const all4 = ref(4)
return {
all4
}
}
}
</script>
:::
::: title 评分属性 ::: title 评分属性
::: :::
@ -82,3 +139,4 @@ export default {
| ------- | -------- | --- | | ------- | -------- | --- |
| v-model | 评分值 | -- | | v-model | 评分值 | -- |
| length | 评分长度 | -- | | length | 评分长度 | -- |
| readonly | 只读模式 | -- |

View File

@ -11,7 +11,13 @@
<template> <template>
<lay-timeline> <lay-timeline>
<lay-timeline-item title="0.2.1"> <lay-timeline-item title="0.2.1">
[新增] hooks 文档
[新增] useClickOutside 外部 click 事件 hooks。<br> [新增] useClickOutside 外部 click 事件 hooks。<br>
[新增] rate 评分 readonly 属性, 支持只读模式。<br>
[新增] rate 评分 theme 属性, 支持自定义主题。<br>
[新增] progress 文档, 区分 theme 与 size 使用案例。<br>
[新增] dropdown 下拉组件 dropdown-item 点击监听, 隐藏 content 内容。<br>
[修复] rate 评分 modelValue 属性, 双绑逻辑。<br>
</lay-timeline-item> </lay-timeline-item>
<lay-timeline-item title="0.2.0"> <lay-timeline-item title="0.2.0">
[新增] carousel 轮播 anim 属性, 支持 default updown 不同方向轮播。<br> [新增] carousel 轮播 anim 属性, 支持 default updown 不同方向轮播。<br>

View File

@ -3,7 +3,19 @@
<br> <br>
- 使用 npm 下载 ::: describe 这里是 Layui 的 Vue 实现,开发和服务于企业级后台产品。
:::
<img src="https://portrait.gitee.com/uploads/avatars/namespace/2849/8547475_layui-vue_1633242524.png" style="margin-left:24px;border-radius: 10px;" width="140px" />
<span style="font-size: 30px;color: #aaa;margin: 0 20px;">+</span>
<img src="https://qn.antdv.com/vue.png" width="160px" />
<br>
<br>
<br>
::: describe 1.使用 npm 下载
:::
``` ```
npm install @layui/layui-vue --save npm install @layui/layui-vue --save
@ -11,7 +23,8 @@ npm install @layui/layui-vue --save
<br> <br>
- 在 main.ts 中 ::: describe 2.在 main.ts 中依赖
:::
```js ```js
import App from './App.vue' import App from './App.vue'
@ -24,7 +37,8 @@ createApp(App).use(Layui).mount('#app')
<br> <br>
- 在 index.vue 使用: ::: describe 3.在 index.vue 使用
:::
```html ```html
<lay-layout> <lay-layout>

View File

@ -1,6 +1,8 @@
::: title 基本介绍 ::: title 基本介绍
::: :::
<img src="http://layui-doc.pearadmin.com/static/images/layui/logo-2.png" />
<br> <br>
::: block ::: block

View File

@ -1,15 +1,31 @@
::: title useClickOutside ::: title 基础使用
::: :::
```html ::: demo 使用 useClickOutside 监听元素外的监听事件
<div ref="dropdownRef"></div>
```
```javascript <template>
const dropdownRef = (ref < null) | (HTMLElement > null) <lay-button ref='buttonRef' type='primary'>当前元素</lay-button>
const isClickOutside = useClickOutside(dropdownRef) </template>
watch(isClickOutside, () => { <script>
// do something import { ref, watch } from 'vue'
}) import useClickOutside from '/@src/hooks/useClickOutside'
```
export default {
setup() {
const buttonRef = (ref < null) | (HTMLElement > null)
const isClickOutside = useClickOutside(buttonRef)
watch(isClickOutside, () => {
console.log("元素外 click 事件")
})
return {
buttonRef
}
}
}
</script>
:::

View File

@ -21,7 +21,7 @@ export default function createContainer(
const token = tokens[idx] const token = tokens[idx]
const info = token.info.trim().slice(klass.length).trim() const info = token.info.trim().slice(klass.length).trim()
if (token.nesting === 1) { if (token.nesting === 1) {
return `<p>${info}` return `<p style="margin-left: 24px;margin-bottom:20px;">${info}`
} else { } else {
return '</p>\n' return '</p>\n'
} }

View File

@ -5,7 +5,7 @@
class="layui-dropdown" class="layui-dropdown"
:class="[openState ? 'layui-dropdown-up' : '']" :class="[openState ? 'layui-dropdown-up' : '']"
> >
<div @click="open"> <div @click="toggle">
<slot /> <slot />
</div> </div>
<dl class="layui-anim layui-anim-upbit"> <dl class="layui-anim layui-anim-upbit">
@ -19,9 +19,11 @@
class="layui-dropdown" class="layui-dropdown"
:class="[openState ? 'layui-dropdown-up' : '']" :class="[openState ? 'layui-dropdown-up' : '']"
@mouseenter="open" @mouseenter="open"
@mouseleave="open" @mouseleave="hide"
> >
<div>
<slot /> <slot />
</div>
<dl class="layui-anim layui-anim-upbit"> <dl class="layui-anim layui-anim-upbit">
<ul class="layui-menu layui-dropdown-menu"> <ul class="layui-menu layui-dropdown-menu">
<slot name="content" /> <slot name="content" />
@ -31,7 +33,7 @@
</template> </template>
<script setup name="LaySelect" lang="ts"> <script setup name="LaySelect" lang="ts">
import { defineProps, ref, watch } from 'vue' import { defineProps, provide, ref, watch } from 'vue'
import useClickOutside from '../../hooks/useClickOutside' import useClickOutside from '../../hooks/useClickOutside'
const dropdownRef = ref<null | HTMLElement>(null) const dropdownRef = ref<null | HTMLElement>(null)
@ -49,6 +51,14 @@ const props = withDefaults(
const openState = ref(false) const openState = ref(false)
const open = function () { const open = function () {
openState.value = true
}
const hide = function () {
openState.value = false
}
const toggle = function () {
openState.value = !openState.value openState.value = !openState.value
} }
@ -57,4 +67,6 @@ watch(isClickOutside, () => {
openState.value = false openState.value = false
} }
}) })
provide('openState', openState)
</script> </script>

View File

@ -1,9 +1,17 @@
<template> <template>
<li> <li>
<div class="layui-menu-body-title"> <div class="layui-menu-body-title" @click="click">
<slot /> <slot />
</div> </div>
</li> </li>
</template> </template>
<script setup name="LayDropdownItem" lang="ts"></script> <script setup name="LayDropdownItem" lang="ts">
import { inject, Ref } from "vue";
const openState:Ref<boolean> = inject('openState') as Ref<boolean>
const click = function () {
openState.value = false
}
</script>

View File

@ -6,46 +6,57 @@
class="layui-inline" class="layui-inline"
@mouseenter="mouseenter(index)" @mouseenter="mouseenter(index)"
> >
<i class="layui-icon" :class="[rate]" /> <i
v-if="rate"
class="layui-icon layui-icon-rate-solid"
:style="{ color: theme }"
/>
<i v-else class="layui-icon layui-icon-rate" :style="{ color: theme }" />
</li> </li>
</ul> </ul>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps, Ref, ref, withDefaults } from 'vue' import { defineProps, Ref, ref, watch, withDefaults } from 'vue'
const rates: Ref<Array<string>> = ref([]) const rates: Ref<Array<boolean>> = ref([])
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
length?: number length?: number
modelValue?: number modelValue?: number
character?: string character?: string
readonly?: boolean
theme?: string
}>(), }>(),
{ {
length: 5, length: 5,
modelValue: 0, modelValue: 0,
readonly: false,
} }
) )
for (let index = 0; index < props.length; index++) { watch(props, function () {
rates.value.push('layui-icon-rate') rates.value = []
} for (let index = 0; index < props.length; index++) {
rates.value.push(false)
for (let index = props.modelValue - 1; index >= 0; index--) { }
rates.value[index] = 'layui-icon-rate-solid' for (let index = props.modelValue - 1; index >= 0; index--) {
} rates.value[index] = true
}
},{deep: true, immediate: true})
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const mouseenter = function (index: number) { const mouseenter = function (index: number) {
if (props.readonly) {
return false
}
for (let i = index; i >= 0; i--) { for (let i = index; i >= 0; i--) {
rates.value[i] = 'layui-icon-rate-solid' rates.value[i] = true
} }
for (let j = index + 1; j < props.length; j++) { for (let i = index + 1; i < props.length; i++) {
rates.value[j] = 'layui-icon-rate' rates.value[i] = false
} }
// select update , change
emit('update:modelValue', index + 1) emit('update:modelValue', index + 1)
} }
</script> </script>