├── .gitignore ├── App.vue ├── README.md ├── components ├── clickCircle.vue ├── navTab.vue ├── refresh.vue └── tabBar4.vue ├── main.js ├── manifest.json ├── pages.json ├── pages ├── index │ └── index.vue ├── longIndex │ └── longIndex.vue └── other │ └── other.vue ├── static ├── icon-search.png ├── icon-yes.png ├── index.png ├── index_change.png └── logo.png ├── uni.scss └── util └── util.js /.gitignore: -------------------------------------------------------------------------------- 1 | /unpackage/ 2 | /node_modules/ -------------------------------------------------------------------------------- /App.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # html tab组件说明 # 2 | 3 | 4 | 5 | //script 6 | // 引入tab 7 | import navTab from "../../components/navTab.vue" 8 | export default { 9 | components: { 10 | navTab 11 | }, 12 | data() { 13 | return { 14 | currentTab: 0, //sweiper所在页 15 | tabTitle:['选择一','选择二','选择三','选择四'], //导航栏格式 16 | } 17 | }, 18 | methods:{ 19 | // tab事件 20 | changeTab(index){ 21 | this.currentTab = index; 22 | }, 23 | // swiper 滑动 如果tab关联swiper需要写下面的方法 否则不写 24 | swiperTab: function(e) { 25 | var index = e.detail.current //获取索引 26 | this.$refs.navTab.longClick(index); 27 | }, 28 | } 29 | }; 30 | 31 | # html 下拉刷新组件说明 # 32 | //最外层加上touch事件 33 | //刷新组件需搭配scroll-view使用,并在pages.json中添加 "disableScroll":true 34 | 39 | 40 | //script 41 | // 引入下拉刷新 42 | import refresh from '../../components/refresh.vue'; 43 | export default { 44 | components: {refresh}, 45 | data() { 46 | return { 47 | 48 | }; 49 | }, 50 | methods: { 51 | refreshStart(e) { 52 | this.$refs.refresh.refreshStart(e); 53 | }, 54 | refreshMove(e){ 55 | this.$refs.refresh.refreshMove(e); 56 | }, 57 | refreshEnd(e) { 58 | this.$refs.refresh.refreshEnd(e); 59 | }, 60 | //刷新名需写为isRefresh,刷新组件中会回调此事件 61 | isRefresh(){ 62 | setTimeout(() => { 63 | uni.showToast({ 64 | icon: 'success', 65 | title: '刷新成功' 66 | }) 67 | this.$refs.refresh.endAfter() //刷新结束调用 68 | }, 1000) 69 | } 70 | } 71 | }; -------------------------------------------------------------------------------- /components/clickCircle.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 48 | 49 | 139 | -------------------------------------------------------------------------------- /components/navTab.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 61 | 62 | 121 | -------------------------------------------------------------------------------- /components/refresh.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 87 | 88 | 175 | -------------------------------------------------------------------------------- /components/tabBar4.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 67 | 68 | 123 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | 4 | Vue.config.productionTip = false 5 | 6 | App.mpType = 'app' 7 | 8 | const app = new Vue({ 9 | ...App 10 | }) 11 | app.$mount() 12 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "列表list左右切换+自定义刷新+加载", 3 | "appid" : "", 4 | "description" : "", 5 | "versionName" : "1.0.0", 6 | "versionCode" : "100", 7 | "transformPx" : false, 8 | /* 5+App特有相关 */ 9 | "app-plus" : { 10 | "usingComponents" : true, 11 | "splashscreen" : { 12 | "alwaysShowBeforeRender" : true, 13 | "waiting" : true, 14 | "autoclose" : true, 15 | "delay" : 0 16 | }, 17 | /* 模块配置 */ 18 | "modules" : {}, 19 | /* 应用发布信息 */ 20 | "distribute" : { 21 | /* android打包配置 */ 22 | "android" : { 23 | "permissions" : [ 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 | /* ios打包配置 */ 49 | "ios" : {}, 50 | /* SDK配置 */ 51 | "sdkConfigs" : {} 52 | } 53 | }, 54 | /* 快应用特有相关 */ 55 | "quickapp" : {}, 56 | /* 小程序特有相关 */ 57 | "mp-weixin" : { 58 | "appid" : "", 59 | "setting" : { 60 | "urlCheck" : false 61 | }, 62 | "usingComponents" : true 63 | }, 64 | "mp-alipay" : { 65 | "usingComponents" : true 66 | }, 67 | "mp-baidu" : { 68 | "usingComponents" : true 69 | }, 70 | "mp-toutiao" : { 71 | "usingComponents" : true 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages 3 | { 4 | "path": "pages/index/index", 5 | "style": { 6 | "navigationBarTitleText": "列表", 7 | "disableScroll":true 8 | } 9 | } 10 | ,{ 11 | "path" : "pages/longIndex/longIndex", 12 | "style" : { 13 | "navigationBarTitleText": "长tab", 14 | "disableScroll":true 15 | } 16 | } 17 | ,{ 18 | "path" : "pages/other/other", 19 | "style" : { 20 | "navigationBarTitleText": "长tab", 21 | "disableScroll":true 22 | } 23 | } 24 | ], 25 | "globalStyle": { 26 | "navigationBarTextStyle": "white", 27 | "navigationBarTitleText": "uni-app", 28 | "navigationBarBackgroundColor": "#50B7EA", 29 | "backgroundColor": "#50B7EA" 30 | }, 31 | "tabBar": { 32 | "color": "#cdcdcd", 33 | "selectedColor": "#50B7EA", 34 | "borderStyle": "white", 35 | "list": [{ 36 | "pagePath": "pages/index/index", 37 | "text": "短tab", 38 | "iconPath": "static/index_change.png", 39 | "selectedIconPath": "static/index.png" 40 | }, 41 | { 42 | "pagePath": "pages/longIndex/longIndex", 43 | "text": "长tab", 44 | "iconPath": "static/index_change.png", 45 | "selectedIconPath": "static/index.png" 46 | }, 47 | { 48 | "pagePath": "pages/other/other", 49 | "text": "其他", 50 | "iconPath": "static/index_change.png", 51 | "selectedIconPath": "static/index.png" 52 | } 53 | ] 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /pages/index/index.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 130 | 131 | 214 | -------------------------------------------------------------------------------- /pages/longIndex/longIndex.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 130 | 131 | 214 | -------------------------------------------------------------------------------- /pages/other/other.vue: -------------------------------------------------------------------------------- 1 | 56 | 57 | 154 | 155 | 259 | -------------------------------------------------------------------------------- /static/icon-search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhcode/uni-list/HEAD/static/icon-search.png -------------------------------------------------------------------------------- /static/icon-yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhcode/uni-list/HEAD/static/icon-yes.png -------------------------------------------------------------------------------- /static/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhcode/uni-list/HEAD/static/index.png -------------------------------------------------------------------------------- /static/index_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhcode/uni-list/HEAD/static/index_change.png -------------------------------------------------------------------------------- /static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhcode/uni-list/HEAD/static/logo.png -------------------------------------------------------------------------------- /uni.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * 这里是uni-app内置的常用样式变量 3 | * 4 | * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 5 | * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App 6 | * 7 | */ 8 | 9 | /** 10 | * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 11 | * 12 | * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 13 | */ 14 | 15 | /* 颜色变量 */ 16 | 17 | /* 行为相关颜色 */ 18 | $uni-color-primary: #007aff; 19 | $uni-color-success: #4cd964; 20 | $uni-color-warning: #f0ad4e; 21 | $uni-color-error: #dd524d; 22 | 23 | /* 文字基本颜色 */ 24 | $uni-text-color:#333;//基本色 25 | $uni-text-color-inverse:#fff;//反色 26 | $uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息 27 | $uni-text-color-placeholder: #808080; 28 | $uni-text-color-disable:#c0c0c0; 29 | 30 | /* 背景颜色 */ 31 | $uni-bg-color:#ffffff; 32 | $uni-bg-color-grey:#f8f8f8; 33 | $uni-bg-color-hover:#f1f1f1;//点击状态颜色 34 | $uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色 35 | 36 | /* 边框颜色 */ 37 | $uni-border-color:#c8c7cc; 38 | 39 | /* 尺寸变量 */ 40 | 41 | /* 文字尺寸 */ 42 | $uni-font-size-sm:24upx; 43 | $uni-font-size-base:28upx; 44 | $uni-font-size-lg:32upx; 45 | 46 | /* 图片尺寸 */ 47 | $uni-img-size-sm:40upx; 48 | $uni-img-size-base:52upx; 49 | $uni-img-size-lg:80upx; 50 | 51 | /* Border Radius */ 52 | $uni-border-radius-sm: 4upx; 53 | $uni-border-radius-base: 6upx; 54 | $uni-border-radius-lg: 12upx; 55 | $uni-border-radius-circle: 50%; 56 | 57 | /* 水平间距 */ 58 | $uni-spacing-row-sm: 10px; 59 | $uni-spacing-row-base: 20upx; 60 | $uni-spacing-row-lg: 30upx; 61 | 62 | /* 垂直间距 */ 63 | $uni-spacing-col-sm: 8upx; 64 | $uni-spacing-col-base: 16upx; 65 | $uni-spacing-col-lg: 24upx; 66 | 67 | /* 透明度 */ 68 | $uni-opacity-disabled: 0.3; // 组件禁用态的透明度 69 | 70 | /* 文章场景相关 */ 71 | $uni-color-title: #2C405A; // 文章标题颜色 72 | $uni-font-size-title:40upx; 73 | $uni-color-subtitle: #555555; // 二级标题颜色 74 | $uni-font-size-subtitle:36upx; 75 | $uni-color-paragraph: #3F536E; // 文章段落颜色 76 | $uni-font-size-paragraph:30upx; -------------------------------------------------------------------------------- /util/util.js: -------------------------------------------------------------------------------- 1 | function throttle(fn, gapTime) { 2 | if (gapTime == null || gapTime == undefined) { 3 | gapTime = 1500 4 | } 5 | 6 | let _lastTime = null 7 | 8 | // 返回新的函数 9 | return function () { 10 | let _nowTime = + new Date() 11 | if (_nowTime - _lastTime > gapTime || !_lastTime) { 12 | fn.apply(this, arguments) //将this和参数传给原函数 13 | _lastTime = _nowTime 14 | } 15 | } 16 | } 17 | 18 | module.exports = { 19 | throttle:throttle, 20 | vuemixin:{ 21 | created: function () { console.log(1) } 22 | } 23 | } --------------------------------------------------------------------------------