From 1c3a51dcc38d4e97d2aaafa46e0a69f287568332 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Thu, 16 May 2024 11:51:11 +0800 Subject: [PATCH] 调整代码格式 --- layout/h5Page/CContent.vue | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/layout/h5Page/CContent.vue b/layout/h5Page/CContent.vue index 775f77c..dff8ecc 100644 --- a/layout/h5Page/CContent.vue +++ b/layout/h5Page/CContent.vue @@ -5,12 +5,51 @@ <template> <view class="c-content"> - <slot /> + <view + class="c-content-inner" + v-if="scroll==='off'" + > + <slot /> + </view> + <scroll-view + class="c-content-scroll" + v-if="scroll==='on'" + :scrollY="true" + :scroll-top="scrollTop" + :scroll-with-animation="true" + ref="scrollor" + @scroll="evt => handleScroll(evt)" + > + <slot /> + </scroll-view> </view> </template> <script> export default { name: 'CContent', + props: { + // 开启滚动,off / on + scroll: { + type: String, + default: 'off', + }, + }, + data() { + return { + scrollTop: '', + }; + }, + methods: { + handleScroll(evt) { + this.scrollTop = evt.target.scrollTop; + }, + $scrollTop(top) { + if (this.scroll === 'off') { + return; + } + this.scrollTop = top || 0; + }, + }, }; </script> \ No newline at end of file -- Gitblit v1.9.1