小程序页面滚动?

要在小程序中实现页面滚动,可以使用 <scroll-view> 组件。以下是一个基本的示例:

javascript 复制代码
<template>
  <scroll-view class="container" scroll-y>
    <!-- 这里放置页面内容 -->
    <view class="content">
      <!-- 页面内容 -->
    </view>
  </scroll-view>
</template>

<script>
export default {
  // 这里是页面逻辑
};
</script>

<style>
.container {
  width: 100%;
  height: 100%;
}

.content {
  width: 100%;
  /* 设置内容高度或使用 flex 布局使其撑开高度 */
}
</style>

在这个示例中,<scroll-view> 组件包裹了页面的内容,通过设置 scroll-y 属性来启用垂直滚动。你可以在 .content 类中添加页面的实际内容,当内容高度超过 <scroll-view> 的高度时,就会出现滚动条

相关推荐
半个落月12 小时前
React 组件通信进阶:useContext 与自定义 Hook 实战详解
前端·react.js
用户9210802628612 小时前
ChatComposer 输入区改造:基于技能市场实现 Agent 输入框
前端
用户459892045651612 小时前
一套 KMP 多仓库版本治理工作流:用 Version Catalog + CI 把发版流水线自动化
前端·kotlin
小赵同学WoW12 小时前
1-4 TypeScript 中的 `number`、`bigint` 与 `string`
前端
小赵同学WoW12 小时前
1-3 `boolean` 与字面量类型
前端
光影少年12 小时前
react navite 长列表优化:FlatList / SectionList 原理与优化属性
前端·react native·react.js
cindershade12 小时前
鼠标 3D 倾斜卡片
前端
wordbaby12 小时前
从双端内卷到一库多端:基于 pnpm + Taro 4 + RNOH 鸿蒙的 Monorepo 跨端架构实战
前端·微信小程序·app
子兮曰13 小时前
DeepSeek Harness 架构深潜:一个把 Agent 运行时做成纯插件树的开源 Harness
前端·后端·deepseek
子兮曰14 小时前
AI Agent 完整入门指南:从 LLM 到生产落地的 30+ 个核心概念
前端·后端·agent