# app_stu **Repository Path**: osvue/app_stu ## Basic Information - **Project Name**: app_stu - **Description**: app for uni-app - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-09-07 - **Last Updated**: 2024-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README --- title: uni --- ## uniapp - 生命周期 onLoad onShow onReady onHide - 页面卸载 + onUnLoad - 页面滚动 - onPageScorll - navigator - rpx 即时设计/masterGo 750px base - css 导入 @import '@/common/css/xxx.css' `@/` 代表根目录 - tabBar 底部 ## 使用自动导入插件unplugin-auto-import - `npm install unplugin-auto-import` - `vite.config.js` ```js import { defineConfig } from 'vite' import uni from '@dcloudio/vite-plugin-uni' import AutoImport from 'unplugin-auto-import/vite' export default defineConfig({ plugins: [ uni(), // 自动导入配置 AutoImport({ imports:[ // 预设 'vue', 'uni-app' ] }) ] }) ``` ### 下拉刷新,回到顶部 ```js import {onReachBottom , onPullDownRefresh} from '@dcloudio/uni-app' // 需要在 pages.json 里,找到的当前页面的pages节点,并在 style 选项中开启 enablePullDownRefresh。 // 当处理完数据刷新后,uni.stopPullDownRefresh 可以停止当前页面的下拉刷新。 { "path": "pages/index/index", "style": { "navigationBarTitleText": "helloworld", "enablePullDownRefresh": true // 下拉刷新 } }, onPullDownRefresh(()=>{ console.log('下拉事件'); setTimeout(()=>{ /** * @see 模拟网路请求,下拉刷新后 返回结果,停止效果 * */ uni.stopPullDownRefresh() },2000) }) // 触底刷新 onReachBottom(()=>{ console.log('触底了'); }) ``` ### 组件的定义 * 约定大于配置,通过名称自动导入,·`components`文件夹下,定义为组件 * 单击右键,创建 组件