|
测试没问题啊
- <template>
- <view>
- <text class="title">垂直滚动</text>
- <scroll-view id="view1" class="scroll-view" scroll-x>
- <view class="item red"></view>
- <view class="item green"></view>
- <view class="item blue"></view>
- </scroll-view>
- <!-- <view class="text" v-if="this.data.a">
- </view> -->
- </view>
- </template>
- <style>
- .text {
- height: 40vw;
- width: 40vw;
- position: absolute;
- top: 50vw;
- right: 50vw;
- background-color: black;
- }
- .scroll-view {
- width: 100%;
- height: 100vh;
- }
- .title {
- padding: 10px 0;
- font-size: 20px;
- }
- .item {
- width: 100%;
- height: 100%;
- }
- .red {
- background-color: #f00;
- }
- .green {
- background-color: #0f0;
- }
- .blue {
- background-color: #00f;
- }
- </style>
- <script>
- export default {
- name: 'test',
- data() {
- return {
- a: 1
- }
- },
- apiready() {
- this.fntest()
- },
- methods: {
- fntest(e) {
- // if (e.detail.scrollTop > 200) {
- // console.log(e.detail.scrollTop);
- // this.data.a = 1
- // } else {
- // this.data.a = 0
- // }
- document.getElementById('view1').scrollTo({
- x: 100
- })
- }
- }
- }
- </script>
复制代码 |
|