scroll-view.uvue 6.3 KB
Newer Older
Y
init  
yurj26 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149




































    export default {
        data() {
            return {
                scrollTop: 0,
                oldScrollTop: 0
            }
        },
        methods: {
            upper: function (e : ScrollToUpperEvent) {
                console.log(e)
            },
            lower: function (e : ScrollToLowerEvent) {
                console.log(e)
            },
            scroll: function (e : ScrollEvent) {
                this.oldScrollTop = e.detail.scrollTop
            },
            goTop: function () {
                // 解决view层不同步的问题
                this.scrollTop = this.oldScrollTop
                this.$nextTick(function () {
                    this.scrollTop = 0
                });
                uni.showToast({
                    icon: "none",
                    title: "纵向滚动 scrollTop 值已被修改为 0"
                })
            }
        }
    }


const GenPagesComponentScrollViewScrollViewStyles = [new Map<string, Map<string, Map<string, any>>>([["common-page-head", new Map<string, any>([["", new Map<string, any>([["paddingTop", "35rpx"], ["paddingRight", "35rpx"], ["paddingBottom", "35rpx"], ["paddingLeft", "35rpx"], ["flexDirection", "row"], ["justifyContent", "center"]])]])], ["common-page-head-title-box", new Map<string, any>([["", new Map<string, any>([["paddingTop", 0], ["paddingRight", "40rpx"], ["paddingBottom", 0], ["paddingLeft", "40rpx"], ["height", "88rpx"], ["borderBottomWidth", "2rpx"], ["borderBottomStyle", "solid"], ["borderBottomColor", "#D8D8D8"]])]])], ["common-page-head-title", new Map<string, any>([["", new Map<string, any>([["lineHeight", "88rpx"], ["fontSize", "30rpx"], ["color", "#BEBEBE"]])]])], ["scroll-Y", new Map<string, any>([["", new Map<string, any>([["height", "300rpx"]])]])], ["scroll-view_H", new Map<string, any>([["", new Map<string, any>([["width", "100%"], ["flexDirection", "row"]])]])], ["scroll-view-item", new Map<string, any>([["", new Map<string, any>([["height", "300rpx"], ["justifyContent", "center"], ["alignItems", "center"]])]])], ["scroll-view-item_H", new Map<string, any>([["", new Map<string, any>([["width", "690rpx"], ["height", "300rpx"], ["justifyContent", "center"], ["alignItems", "center"]])]])], ["text", new Map<string, any>([["", new Map<string, any>([["fontSize", "36rpx"], ["color", "#ffffff"]])]])]])]
@Suppress("UNUSED_PARAMETER") function GenPagesComponentScrollViewScrollViewRender(_ctx: GenPagesComponentScrollViewScrollView): VNode | null {
const _component_page_head = resolveComponent("page-head")

  return createElementVNode("view", null, [
    createVNode(_component_page_head, new Map<string, any | null>([["title", "scroll-view,区域滚动视图"]])),
    createElementVNode("view", new Map<string, any | null>([["class", "uni-padding-wrap uni-common-mt"]]), [
      createElementVNode("view", new Map<string, any | null>([["class", "uni-title uni-common-mt"]]), [
        createElementVNode("text", new Map<string, any | null>([["class", "uni-title-text"]]), "Vertical Scroll"),
        createElementVNode("text", new Map<string, any | null>([["class", "uni-subtitle-text"]]), "纵向滚动")
      ]),
      createElementVNode("view", null, [
        createElementVNode("scroll-view", new Map<string, any | null>([
          ["scrollTop", _ctx.scrollTop],
          ["scrollY", true],
          ["class", "scroll-Y"],
          ["onScrolltoupper", _ctx.upper],
          ["onScrolltolower", _ctx.lower],
          ["onScroll", _ctx.scroll]
        ]), [
          createElementVNode("view", new Map<string, any | null>([
            ["id", "demo1"],
            ["class", "scroll-view-item uni-bg-red"]
          ]), [
            createElementVNode("text", new Map<string, any | null>([["class", "text"]]), "A")
          ]),
          createElementVNode("view", new Map<string, any | null>([
            ["id", "demo2"],
            ["class", "scroll-view-item uni-bg-green"]
          ]), [
            createElementVNode("text", new Map<string, any | null>([["class", "text"]]), "B")
          ]),
          createElementVNode("view", new Map<string, any | null>([
            ["id", "demo3"],
            ["class", "scroll-view-item uni-bg-blue"]
          ]), [
            createElementVNode("text", new Map<string, any | null>([["class", "text"]]), "C")
          ])
        ], 40 /* PROPS, HYDRATE_EVENTS */, ["scrollTop", "onScrolltoupper", "onScrolltolower", "onScroll"])
      ]),
      createElementVNode("view", new Map<string, any | null>([
        ["onClick", _ctx.goTop],
        ["class", "uni-center uni-common-mt"]
      ]), [
        createElementVNode("text", new Map<string, any | null>([["class", "uni-link"]]), "点击这里返回顶部")
      ], 8 /* PROPS */, ["onClick"]),
      createElementVNode("view", new Map<string, any | null>([["class", "uni-title uni-common-mt"]]), [
        createElementVNode("text", new Map<string, any | null>([["class", "uni-title-text"]]), "Horizontal Scroll"),
        createElementVNode("text", new Map<string, any | null>([["class", "uni-subtitle-text"]]), "横向滚动")
      ]),
      createElementVNode("view", null, [
        createElementVNode("scroll-view", new Map<string, any | null>([
          ["class", "scroll-view_H"],
          ["scrollX", true],
          ["onScroll", _ctx.scroll],
          ["scrollLeft", 120]
        ]), [
          createElementVNode("view", new Map<string, any | null>([
            ["id", "demo1"],
            ["class", "scroll-view-item_H uni-bg-red"]
          ]), [
            createElementVNode("text", new Map<string, any | null>([["class", "text"]]), "A")
          ]),
          createElementVNode("view", new Map<string, any | null>([
            ["id", "demo2"],
            ["class", "scroll-view-item_H uni-bg-green"]
          ]), [
            createElementVNode("text", new Map<string, any | null>([["class", "text"]]), "B")
          ]),
          createElementVNode("view", new Map<string, any | null>([
            ["id", "demo3"],
            ["class", "scroll-view-item_H uni-bg-blue"]
          ]), [
            createElementVNode("text", new Map<string, any | null>([["class", "text"]]), "C")
          ])
        ], 40 /* PROPS, HYDRATE_EVENTS */, ["onScroll"])
      ]),
      createElementVNode("view", new Map<string, any | null>([["class", "uni-common-pb"]]))
    ])
  ])
}