u-tabs.js.map
25.5 KB
{"version":3,"sources":["webpack:////Users/juvenile/Documents/web/xiaoai/excellent-working/uview-ui/components/u-tabs/u-tabs.vue?0b4e","webpack:////Users/juvenile/Documents/web/xiaoai/excellent-working/uview-ui/components/u-tabs/u-tabs.vue?7338","webpack:////Users/juvenile/Documents/web/xiaoai/excellent-working/uview-ui/components/u-tabs/u-tabs.vue?e10c","webpack:////Users/juvenile/Documents/web/xiaoai/excellent-working/uview-ui/components/u-tabs/u-tabs.vue?aa41","uni-app:///uview-ui/components/u-tabs/u-tabs.vue","webpack:////Users/juvenile/Documents/web/xiaoai/excellent-working/uview-ui/components/u-tabs/u-tabs.vue?ab49","webpack:////Users/juvenile/Documents/web/xiaoai/excellent-working/uview-ui/components/u-tabs/u-tabs.vue?3b68"],"names":[],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA+H;AAC/H;AAC0D;AACL;AACsC;;;AAG3F;AACsN;AACtN,gBAAgB,iNAAU;AAC1B,EAAE,4EAAM;AACR,EAAE,6FAAM;AACR,EAAE,sGAAe;AACjB;AACA;AACA;AACA;AACA;AACA,EAAE,iGAAU;AACZ;AACA;;AAEA;AACe,gF;;;;;;;;;;;;ACvBf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA,aAAa,8MAEN;AACP;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACtDA;AAAA;AAAA;AAAA;AAAk2B,CAAgB,oyBAAG,EAAC,C;;;;;;;;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;;;;ACA/lD;AACA,OAAO,KAAU,EAAE,kBAKd","file":"uview-ui/components/u-tabs/u-tabs.js","sourcesContent":["import { render, staticRenderFns, recyclableRender, components } from \"./u-tabs.vue?vue&type=template&id=3b2b1a80&scoped=true&\"\nvar renderjs\nimport script from \"./u-tabs.vue?vue&type=script&lang=js&\"\nexport * from \"./u-tabs.vue?vue&type=script&lang=js&\"\nimport style0 from \"./u-tabs.vue?vue&type=style&index=0&id=3b2b1a80&lang=scss&scoped=true&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"3b2b1a80\",\n null,\n false,\n components,\n renderjs\n)\n\ncomponent.options.__file = \"uview-ui/components/u-tabs/u-tabs.vue\"\nexport default component.exports","export * from \"-!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--16-0!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/template.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-app-loader/page-meta.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./u-tabs.vue?vue&type=template&id=3b2b1a80&scoped=true&\"","var components\ntry {\n components = {\n uBadge: function() {\n return import(\n /* webpackChunkName: \"uview-ui/components/u-badge/u-badge\" */ \"@/uview-ui/components/u-badge/u-badge.vue\"\n )\n }\n }\n} catch (e) {\n if (\n e.message.indexOf(\"Cannot find module\") !== -1 &&\n e.message.indexOf(\".vue\") !== -1\n ) {\n console.error(e.message)\n console.error(\"1. 排查组件名称拼写是否正确\")\n console.error(\n \"2. 排查组件是否符合 easycom 规范,文档:https://uniapp.dcloud.net.cn/collocation/pages?id=easycom\"\n )\n console.error(\n \"3. 若组件不符合 easycom 规范,需手动引入,并在 components 中注册该组件\"\n )\n } else {\n throw e\n }\n}\nvar render = function() {\n var _vm = this\n var _h = _vm.$createElement\n var _c = _vm._self._c || _h\n var l0 = _vm.__map(_vm.list, function(item, index) {\n var $orig = _vm.__get_orig(item)\n\n var s0 = _vm.__get_style([_vm.tabItemStyle(index)])\n\n return {\n $orig: $orig,\n s0: s0\n }\n })\n\n var s1 = _vm.showBar ? _vm.__get_style([_vm.tabBarStyle]) : null\n _vm.$mp.data = Object.assign(\n {},\n {\n $root: {\n l0: l0,\n s1: s1\n }\n }\n )\n}\nvar recyclableRender = false\nvar staticRenderFns = []\nrender._withStripped = true\n\nexport { render, staticRenderFns, recyclableRender, components }","import mod from \"-!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/babel-loader/lib/index.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--12-1!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./u-tabs.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/babel-loader/lib/index.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--12-1!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./u-tabs.vue?vue&type=script&lang=js&\"","<template>\n\t<view class=\"u-tabs\" :style=\"{\n\t\tbackground: bgColor\n\t}\">\n\t\t<!-- $u.getRect()对组件根节点无效,因为写了.in(this),故这里获取内层接点尺寸 -->\n\t\t<view>\n\t\t\t<scroll-view scroll-x class=\"u-scroll-view\" :scroll-left=\"scrollLeft\" scroll-with-animation>\n\t\t\t\t<view class=\"u-scroll-box\" :id=\"id\" :class=\"{'u-tabs-scorll-flex': !isScroll}\">\n\t\t\t\t\t<view class=\"u-tab-item u-line-1\" :id=\"'u-tab-item-' + index\" v-for=\"(item, index) in list\" :key=\"index\" @tap=\"clickTab(index)\"\n\t\t\t\t\t :style=\"[tabItemStyle(index)]\">\n\t\t\t\t\t\t<u-badge :count=\"item[count] || item['count'] || 0\" :offset=\"offset\" size=\"mini\"></u-badge>\n\t\t\t\t\t\t{{ item[name] || item['name']}}\n\t\t\t\t\t</view>\n\t\t\t\t\t<view v-if=\"showBar\" class=\"u-tab-bar\" :style=\"[tabBarStyle]\"></view>\n\t\t\t\t</view>\n\t\t\t</scroll-view>\n\t\t</view>\n\t</view>\n</template>\n\n<script>\n\t/**\n\t * tabs 标签\n\t * @description 该组件,是一个tabs标签组件,在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。\n\t * @tutorial https://www.uviewui.com/components/tabs.html\n\t * @property {Boolean} is-scroll tabs是否可以左右拖动(默认true)\n\t * @property {Array} list 标签数组,元素为对象,如[{name: '推荐'}]\n\t * @property {String Number} current 指定哪个tab为激活状态(默认0)\n\t * @property {String Number} height 导航栏的高度,单位rpx(默认80)\n\t * @property {String Number} font-size tab文字大小,单位rpx(默认30)\n\t * @property {String Number} duration 滑块移动一次所需的时间,单位秒(默认0.5)\n\t * @property {String} active-color 滑块和激活tab文字的颜色(默认#2979ff)\n\t * @property {String} inactive-color tabs文字颜色(默认#303133)\n\t * @property {String Number} bar-width 滑块宽度,单位rpx(默认40)\n\t * @property {Object} active-item-style 活动tabs item的样式,对象形式\n\t * @property {Object} bar-style 底部滑块的样式,对象形式\n\t * @property {Boolean} show-bar 是否显示底部的滑块(默认true)\n\t * @property {String Number} bar-height 滑块高度,单位rpx(默认6)\n\t * @property {String Number} item-width 标签的宽度(默认auto)\n\t * @property {String Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40)\n\t * @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff)\n\t * @property {String} name 组件内部读取的list参数中的属性名(tab名称),见官网说明(默认name)\n\t * @property {String} count 组件内部读取的list参数中的属性名(badge徽标数),同name属性的使用,见官网说明(默认count)\n\t * @property {Array} offset 设置badge徽标数的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx(默认[5, 20])\n\t * @property {Boolean} bold 激活选项的字体是否加粗(默认true)\n\t * @event {Function} change 点击标签时触发\n\t * @example <u-tabs ref=\"tabs\" :list=\"list\" :is-scroll=\"false\"></u-tabs>\n\t */\n\texport default {\n\t\tname: \"u-tabs\",\n\t\tprops: {\n\t\t\t// 导航菜单是否需要滚动,如只有2或者3个的时候,就不需要滚动了,此时使用flex平分tab的宽度\n\t\t\tisScroll: {\n\t\t\t\ttype: Boolean,\n\t\t\t\tdefault: true\n\t\t\t},\n\t\t\t//需循环的标签列表\n\t\t\tlist: {\n\t\t\t\ttype: Array,\n\t\t\t\tdefault () {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t},\n\t\t\t// 当前活动tab的索引\n\t\t\tcurrent: {\n\t\t\t\ttype: [Number, String],\n\t\t\t\tdefault: 0\n\t\t\t},\n\t\t\t// 导航栏的高度和行高\n\t\t\theight: {\n\t\t\t\ttype: [String, Number],\n\t\t\t\tdefault: 80\n\t\t\t},\n\t\t\t// 字体大小\n\t\t\tfontSize: {\n\t\t\t\ttype: [String, Number],\n\t\t\t\tdefault: 30\n\t\t\t},\n\t\t\t// 过渡动画时长, 单位ms\n\t\t\tduration: {\n\t\t\t\ttype: [String, Number],\n\t\t\t\tdefault: 0.5\n\t\t\t},\n\t\t\t// 选中项的主题颜色\n\t\t\tactiveColor: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '#2979ff'\n\t\t\t},\n\t\t\t// 未选中项的颜色\n\t\t\tinactiveColor: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '#303133'\n\t\t\t},\n\t\t\t// 菜单底部移动的bar的宽度,单位rpx\n\t\t\tbarWidth: {\n\t\t\t\ttype: [String, Number],\n\t\t\t\tdefault: 40\n\t\t\t},\n\t\t\t// 移动bar的高度\n\t\t\tbarHeight: {\n\t\t\t\ttype: [String, Number],\n\t\t\t\tdefault: 6\n\t\t\t},\n\t\t\t// 单个tab的左或有内边距(左右相同)\n\t\t\tgutter: {\n\t\t\t\ttype: [String, Number],\n\t\t\t\tdefault: 30\n\t\t\t},\n\t\t\t// 导航栏的背景颜色\n\t\t\tbgColor: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '#ffffff'\n\t\t\t},\n\t\t\t// 读取传入的数组对象的属性(tab名称)\n\t\t\tname: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: 'name'\n\t\t\t},\n\t\t\t// 读取传入的数组对象的属性(徽标数)\n\t\t\tcount: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: 'count'\n\t\t\t},\n\t\t\t// 徽标数位置偏移\n\t\t\toffset: {\n\t\t\t\ttype: Array,\n\t\t\t\tdefault: () => {\n\t\t\t\t\treturn [5, 20]\n\t\t\t\t}\n\t\t\t},\n\t\t\t// 活动tab字体是否加粗\n\t\t\tbold: {\n\t\t\t\ttype: Boolean,\n\t\t\t\tdefault: true\n\t\t\t},\n\t\t\t// 当前活动tab item的样式\n\t\t\tactiveItemStyle: {\n\t\t\t\ttype: Object,\n\t\t\t\tdefault() {\n\t\t\t\t\treturn {}\n\t\t\t\t}\n\t\t\t},\n\t\t\t// 是否显示底部的滑块\n\t\t\tshowBar: {\n\t\t\t\ttype: Boolean,\n\t\t\t\tdefault: true\n\t\t\t},\n\t\t\t// 底部滑块的自定义样式\n\t\t\tbarStyle: {\n\t\t\t\ttype: Object,\n\t\t\t\tdefault() {\n\t\t\t\t\treturn {}\n\t\t\t\t}\n\t\t\t},\n\t\t\t// 标签的宽度\n\t\t\titemWidth: {\n\t\t\t\ttype: [Number, String],\n\t\t\t\tdefault: 'auto'\n\t\t\t}\n\t\t},\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\tscrollLeft: 0, // 滚动scroll-view的左边滚动距离\n\t\t\t\ttabQueryInfo: [], // 存放对tab菜单查询后的节点信息\n\t\t\t\tcomponentWidth: 0, // 屏幕宽度,单位为px\n\t\t\t\tscrollBarLeft: 0, // 移动bar需要通过translateX()移动的距离\n\t\t\t\tparentLeft: 0, // 父元素(tabs组件)到屏幕左边的距离\n\t\t\t\tid: this.$u.guid(), // id值\n\t\t\t\tcurrentIndex: this.current,\n\t\t\t\tbarFirstTimeMove: true, // 滑块第一次移动时(页面刚生成时),无需动画,否则给人怪异的感觉\n\t\t\t};\n\t\t},\n\t\twatch: {\n\t\t\t// 监听tab的变化,重新计算tab菜单的布局信息,因为实际使用中菜单可能是通过\n\t\t\t// 后台获取的(如新闻app顶部的菜单),获取返回需要一定时间,所以list变化时,重新获取布局信息\n\t\t\tlist(n, o) {\n\t\t\t\t// list变动时,重制内部索引,否则可能导致超出数组边界的情况\n\t\t\t\tif(n.length !== o.length) this.currentIndex = 0;\n\t\t\t\t// 用$nextTick等待视图更新完毕后再计算tab的局部信息,否则可能因为tab还没生成就获取,就会有问题\n\t\t\t\tthis.$nextTick(() => {\n\t\t\t\t\tthis.init();\n\t\t\t\t});\n\t\t\t},\n\t\t\tcurrent: {\n\t\t\t\timmediate: true,\n\t\t\t\thandler(nVal, oVal) {\n\t\t\t\t\t// 视图更新后再执行移动操作\n\t\t\t\t\tthis.$nextTick(() => {\n\t\t\t\t\t\tthis.currentIndex = nVal;\n\t\t\t\t\t\tthis.scrollByIndex();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tcomputed: {\n\t\t\t// 移动bar的样式\n\t\t\ttabBarStyle() {\n\t\t\t\tlet style = {\n\t\t\t\t\twidth: this.barWidth + 'rpx',\n\t\t\t\t\ttransform: `translate(${this.scrollBarLeft}px, -100%)`,\n\t\t\t\t\t// 滑块在页面渲染后第一次滑动时,无需动画效果\n\t\t\t\t\t'transition-duration': `${this.barFirstTimeMove ? 0 : this.duration }s`,\n\t\t\t\t\t'background-color': this.activeColor,\n\t\t\t\t\theight: this.barHeight + 'rpx',\n\t\t\t\t\topacity: this.barFirstTimeMove ? 0 : 1,\n\t\t\t\t\t// 设置一个很大的值,它会自动取能用的最大值,不用高度的一半,是因为高度可能是单数,会有小数出现\n\t\t\t\t\t'border-radius': `${this.barHeight / 2}px`\n\t\t\t\t};\n\t\t\t\tObject.assign(style, this.barStyle);\n\t\t\t\treturn style;\n\t\t\t},\n\t\t\t// tab的样式\n\t\t\ttabItemStyle() {\n\t\t\t\treturn (index) => {\n\t\t\t\t\tlet style = {\n\t\t\t\t\t\theight: this.height + 'rpx',\n\t\t\t\t\t\t'line-height': this.height + 'rpx',\n\t\t\t\t\t\t'font-size': this.fontSize + 'rpx',\n\t\t\t\t\t\t'transition-duration': `${this.duration}s`,\n\t\t\t\t\t\tpadding: this.isScroll ? `0 ${this.gutter}rpx` : '',\n\t\t\t\t\t\tflex: this.isScroll ? 'auto' : '1',\n\t\t\t\t\t\twidth: this.$u.addUnit(this.itemWidth)\n\t\t\t\t\t};\n\t\t\t\t\t// 字体加粗\n\t\t\t\t\tif (index == this.currentIndex && this.bold) style.fontWeight = 'bold';\n\t\t\t\t\tif (index == this.currentIndex) {\n\t\t\t\t\t\tstyle.color = this.activeColor;\n\t\t\t\t\t\t// 给选中的tab item添加外部自定义的样式\n\t\t\t\t\t\tstyle = Object.assign(style, this.activeItemStyle);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstyle.color = this.inactiveColor;\n\t\t\t\t\t}\n\t\t\t\t\treturn style;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmethods: {\n\t\t\t// 设置一个init方法,方便多处调用\n\t\t\tasync init() {\n\t\t\t\t// 获取tabs组件的尺寸信息\n\t\t\t\tlet tabRect = await this.$uGetRect('#' + this.id);\n\t\t\t\t// tabs组件距离屏幕左边的宽度\n\t\t\t\tthis.parentLeft = tabRect.left;\n\t\t\t\t// tabs组件的宽度\n\t\t\t\tthis.componentWidth = tabRect.width;\n\t\t\t\tthis.getTabRect();\n\t\t\t},\n\t\t\t// 点击某一个tab菜单\n\t\t\tclickTab(index) {\n\t\t\t\t// 点击当前活动tab,不触发事件\n\t\t\t\tif(index == this.currentIndex) return ;\n\t\t\t\t// 发送事件给父组件\n\t\t\t\tthis.$emit('change', index);\n\t\t\t},\n\t\t\t// 查询tab的布局信息\n\t\t\tgetTabRect() {\n\t\t\t\t// 创建节点查询\n\t\t\t\tlet query = uni.createSelectorQuery().in(this);\n\t\t\t\t// 历遍所有tab,这里是执行了查询,最终使用exec()会一次性返回查询的数组结果\n\t\t\t\tfor (let i = 0; i < this.list.length; i++) {\n\t\t\t\t\t// 只要size和rect两个参数\n\t\t\t\t\tquery.select(`#u-tab-item-${i}`).fields({\n\t\t\t\t\t\tsize: true,\n\t\t\t\t\t\trect: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// 执行查询,一次性获取多个结果\n\t\t\t\tquery.exec(\n\t\t\t\t\tfunction(res) {\n\t\t\t\t\t\tthis.tabQueryInfo = res;\n\t\t\t\t\t\t// 初始化滚动条和移动bar的位置\n\t\t\t\t\t\tthis.scrollByIndex();\n\t\t\t\t\t}.bind(this)\n\t\t\t\t);\n\t\t\t},\n\t\t\t// 滚动scroll-view,让活动的tab处于屏幕的中间位置\n\t\t\tscrollByIndex() {\n\t\t\t\t// 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息\n\t\t\t\tlet tabInfo = this.tabQueryInfo[this.currentIndex];\n\t\t\t\tif (!tabInfo) return;\n\t\t\t\t// 活动tab的宽度\n\t\t\t\tlet tabWidth = tabInfo.width;\n\t\t\t\t// 活动item的左边到tabs组件左边的距离,用item的left减去tabs的left\n\t\t\t\tlet offsetLeft = tabInfo.left - this.parentLeft;\n\t\t\t\t// 将活动的tabs-item移动到屏幕正中间,实际上是对scroll-view的移动\n\t\t\t\tlet scrollLeft = offsetLeft - (this.componentWidth - tabWidth) / 2;\n\t\t\t\tthis.scrollLeft = scrollLeft < 0 ? 0 : scrollLeft;\n\t\t\t\t// 当前活动item的中点点到左边的距离减去滑块宽度的一半,即可得到滑块所需的移动距离\n\t\t\t\tlet left = tabInfo.left + tabInfo.width / 2 - this.parentLeft;\n\t\t\t\t// 计算当前活跃item到组件左边的距离\n\t\t\t\tthis.scrollBarLeft = left - uni.upx2px(this.barWidth) / 2;\n\t\t\t\t// 第一次移动滑块的时候,barFirstTimeMove为true,放到延时中将其设置false\n\t\t\t\t// 延时是因为scrollBarLeft作用于computed计算时,需要一个过程需,否则导致出错\n\t\t\t\tif(this.barFirstTimeMove == true) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis.barFirstTimeMove = false;\n\t\t\t\t\t}, 100)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmounted() {\n\t\t\tthis.init();\n\t\t}\n\t};\n</script>\n\n<style lang=\"scss\" scoped>\n\t@import \"../../libs/css/style.components.scss\";\n\n\tview,\n\tscroll-view {\n\t\tbox-sizing: border-box;\n\t}\n\n\t/* #ifndef APP-NVUE */\n\t::-webkit-scrollbar,\n\t::-webkit-scrollbar,\n\t::-webkit-scrollbar {\n\t\tdisplay: none;\n\t\twidth: 0 !important;\n\t\theight: 0 !important;\n\t\t-webkit-appearance: none;\n\t\tbackground: transparent;\n\t}\n\t/* #endif */\n\n\t.u-scroll-box {\n\t\tposition: relative;\n\t\t/* #ifdef MP-TOUTIAO */\n\t\twhite-space: nowrap;\n\t\t/* #endif */\n\t}\n\n\t/* #ifdef H5 */\n\t// 通过样式穿透,隐藏H5下,scroll-view下的滚动条\n\tscroll-view ::v-deep ::-webkit-scrollbar {\n\t\tdisplay: none;\n\t\twidth: 0 !important;\n\t\theight: 0 !important;\n\t\t-webkit-appearance: none;\n\t\tbackground: transparent;\n\t}\n\t/* #endif */\n\n\t.u-scroll-view {\n\t\twidth: 100%;\n\t\twhite-space: nowrap;\n\t\tposition: relative;\n\t}\n\n\t.u-tab-item {\n\t\tposition: relative;\n\t\t/* #ifndef APP-NVUE */\n\t\tdisplay: inline-block;\n\t\t/* #endif */\n\t\ttext-align: center;\n\t\ttransition-property: background-color, color;\n\t}\n\n\t.u-tab-bar {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t}\n\n\t.u-tabs-scorll-flex {\n\t\t@include vue-flex;\n\t\tjustify-content: space-between;\n\t}\n</style>\n","import mod from \"-!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/mini-css-extract-plugin/dist/loader.js??ref--8-oneOf-1-0!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/stylePostLoader.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--8-oneOf-1-2!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-3!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-4!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--8-oneOf-1-5!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./u-tabs.vue?vue&type=style&index=0&id=3b2b1a80&lang=scss&scoped=true&\"; export default mod; export * from \"-!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/mini-css-extract-plugin/dist/loader.js??ref--8-oneOf-1-0!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/stylePostLoader.js!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--8-oneOf-1-2!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-3!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-4!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--8-oneOf-1-5!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../../../../../../../../Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./u-tabs.vue?vue&type=style&index=0&id=3b2b1a80&lang=scss&scoped=true&\"","// extracted by mini-css-extract-plugin\n if(module.hot) {\n // 1700461803233\n var cssReload = require(\"/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/mini-css-extract-plugin/dist/hmr/hotModuleReplacement.js\")(module.id, {\"hmr\":true,\"publicPath\":\"../../\",\"locals\":false});\n module.hot.dispose(cssReload);\n module.hot.accept(undefined, cssReload);\n }\n "],"sourceRoot":""}