-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loading): loading新增attach、fullscreen属性,支持函数式调用 (#1444)
* feat(loading): loading新增attach、fullscreen属性,支持函数式调用 * feat(loading): 组件示例更新 * fix: fix lint * chore(Loading): add loadingPlugin to plugins file --------- Co-authored-by: anlyyao <[email protected]>
- Loading branch information
Showing
14 changed files
with
345 additions
and
3 deletions.
There are no files selected for viewing
Submodule _common
updated
4 files
+12 −0 | docs/mobile/api_v2/loading.en-US.md | |
+12 −0 | docs/mobile/api_v2/loading.md | |
+36 −0 | style/mobile/components/loading/_index.less | |
+2 −0 | style/mobile/components/loading/_var.less |
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 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,25 @@ | ||
<template> | ||
<div class="loading-demo"> | ||
<div id="alice" class="loading-attach-demo__title">Hello, I'm Alice. I'm going to be a front-end developer.</div> | ||
<t-loading attach="#alice" size="small" :loading="loading"></t-loading> | ||
<t-switch v-model="loading" :custom-value="[true, false]" size="small" :label="['开', '关']" /> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { Switch as TSwitch } from 'tdesign-mobile-vue'; | ||
const loading = ref(false); | ||
</script> | ||
|
||
<style scoped> | ||
.loading-demo { | ||
padding: 0 16px; | ||
} | ||
.loading-attach-demo__title { | ||
/** `position: relative` is required as a parent node */ | ||
position: relative; | ||
width: 360px; | ||
text-align: center; | ||
} | ||
</style> |
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,32 @@ | ||
<template> | ||
<div class="loading-demo"> | ||
<t-loading :loading="loading" text="加载中..." fullscreen /> | ||
<div> | ||
全局加载开关(开启加载1秒后自动归位): | ||
<t-switch v-model="loading" size="small"></t-switch> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue'; | ||
import { Switch as TSwitch } from 'tdesign-mobile-vue'; | ||
const loading = ref(false); | ||
watch( | ||
() => loading.value, | ||
(v) => { | ||
if (!v) return; | ||
const timer = setTimeout(() => { | ||
loading.value = false; | ||
clearTimeout(timer); | ||
}, 1000); | ||
}, | ||
); | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.loading-demo { | ||
padding: 0 16px; | ||
} | ||
</style> |
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 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,62 @@ | ||
<template> | ||
<div class="loading-demo"> | ||
<div id="loading-service-demo" ref="content" class="loading-service-demo">Loading 挂载容器</div> | ||
<div class="space"> | ||
<t-button class="t-loading__btn" size="small" :disabled="attachLoading" @click="showAttach"> | ||
函数方式加载(局部) | ||
</t-button> | ||
<t-button size="small" @click="showFullScreen">函数方式加载(全屏)</t-button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { LoadingPlugin, Button as TButton } from 'tdesign-mobile-vue'; | ||
const content = ref(null); | ||
const attachLoading = ref(false); | ||
// 函数式:局部加载 | ||
const showAttach = () => { | ||
const loadingAttachInstance = LoadingPlugin({ | ||
attach: () => content.value, // 等于 attach: '#loading-service-demo' | ||
size: '20px', | ||
}); | ||
attachLoading.value = true; | ||
const timer = setTimeout(() => { | ||
loadingAttachInstance.hide(); | ||
attachLoading.value = false; | ||
clearTimeout(timer); | ||
}, 1000); | ||
}; | ||
// 函数式:全屏加载,防止滚动穿透 | ||
const showFullScreen = () => { | ||
LoadingPlugin(true); | ||
const timer = setTimeout(() => { | ||
LoadingPlugin(false); | ||
clearTimeout(timer); | ||
}, 1000); | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.loading-demo { | ||
padding: 0 16px; | ||
} | ||
.space { | ||
display: flex; | ||
margin-top: 8px; | ||
gap: 6px; | ||
} | ||
.loading-service-demo { | ||
position: relative; | ||
width: 100%; | ||
height: 64px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: 1px var(--component-border, #eee) solid; | ||
} | ||
</style> |
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 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 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 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
Oops, something went wrong.