uniapp学习(004-2 组件 Part.2生命周期)

零基础入门uniapp Vue3组合式API版本到咸虾米壁纸项目实战,开发打包微信小程序、抖音小程序、H5、安卓APP客户端等

总时长 23:40:00 共116P

此文章包含第31p-第p35的内容


组件生命周期

在这里插入图片描述

在这里插入图片描述
小程序分应用生命周期,组件生命周期,页面生命周期
在这里插入图片描述

这里详见
uniappVue3版本中组件生命周期和页面生命周期的详细介绍

在这里插入图片描述

在这里插入图片描述

引用上方的链接的图片
在这里插入图片描述
在这里插入图片描述


vue3官方页面的查看方法
在这里插入图片描述

我们主要使用的三种生命周期

这里我们主要使用三种生命周期:setup(创建组件时运行)、onMounted(挂载到dom时运行) 、onUnmounted(销毁时)

setup(创建组件时执行)

不可以操作dom节点

在标签里添加 ref=“节点名”
在script里定义 这个节点 = ref(null); 这时候因为在setup生命周期里,我们无法得到dom

在这里插入图片描述
值为null
在这里插入图片描述

onMounted(挂载到dom时执行)

可以操作dom节点

在标签里添加 ref=“节点名”
在script里定义 这个节点 = ref(null); 这时候因为在setup生命周期里,我们无法得到dom

代表虚拟dom变成真实dom了之后执行
在这里插入图片描述
值为dom元素
在这里插入图片描述

在这里插入图片描述

ps:这个REF和vue3还不一样,vue3里的是dom,uniapp是proxy

onUnmounted(销毁前执行)

我们定义一个子组件,并且设置一个onUnmounted,在父组件上引用
在这里插入图片描述

我们设置一个定时器 2秒后v-if=false 销毁这个子组件
在这里插入图片描述
一开始
在这里插入图片描述

两秒后
在这里插入图片描述

defineExpose 父组件直接获取子组件的数据

翻译:
define 英[dɪˈfaɪn] 美[dɪˈfaɪn] 定义
expose 英[ɪkˈspəʊz] 美[ɪkˈspoʊz] 暴露


子组件
在这里插入图片描述

暴露对象

使用defineExpose 把子组件的count向外导出
名字一样可以简写,{count:count}可以简写成{count}
在这里插入图片描述

在父页面调用
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

暴露方法

在这里插入图片描述

调用子组件暴露的++方法,修改子组件的值

在这里插入图片描述
初始样式 在这里插入图片描述
点击后
在这里插入图片描述

vue查看api

在这里插入图片描述

在这里插入图片描述

页面生命周期

在这里插入图片描述

onload

onload生命周期位置(beforeCreate之前)
主要作用就是接收url上的参数

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

写一个跳转url

在这里插入图片描述

这里可以得到页面的url参数
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

onReady

类似组件生命周期里的onMounted
在这里插入图片描述
在dom上定义
在这里插入图片描述
在这里插入图片描述

onShow和onHide

onShow

在这里插入图片描述

离开页面后,在另一个页面点击返回箭头的时候触发onShow
在这里插入图片描述
在这里插入图片描述

onHide

在这里插入图片描述
当我们离开页面的时候触发

例子

写一个计数器,每50毫秒加一
在这里插入图片描述
在这里插入图片描述

离开页面的时候停止计数器
在这里插入图片描述

回归页面的时候开始计数器
在这里插入图片描述

App.vue里也有生命周期(应用的生命周期)

在这里插入图片描述

这里的onLaunch可以判断有无登录信息等
这里的onShow onHide是整个应用进入和离开的时候调用

执行顺序

进入时顺序
在这里插入图片描述

离开时顺序
在这里插入图片描述
不用的时候可以去掉日志打印
在这里插入图片描述

onUnload

在这里插入图片描述

使用navigator跳转并且销毁之前的页面的时候触发
销毁使用 open-type=“reLaunch”
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
跳转到demo4的时候调用了onUnload
在这里插入图片描述
可以对一些缓存信息进行清理
在这里插入图片描述

onPageScroll 监听页面的滚动

在这里插入图片描述
在这里插入图片描述
滚动时
在这里插入图片描述
大于200的时候显示回到顶部,小于200时隐藏
在这里插入图片描述
简化写法
在这里插入图片描述

执行顺序

在这里插入图片描述
在这里插入图片描述


将以下代码转化为uniapp写法<template> <div class="wapper"> <div class="info_wapper"> <div class="line_info"> <div class="site"> <span class="from" id="from">{{ from }}</span> <span class="to" id="to">{{ to }}</span> </div> <div class="tit"> <span class="time_s">首班:<strong >{{ time_s }}</strong></span> <span class="time_e">末班:<strong >{{ time_e }}</strong></span> <span class="price">票价:<strong >{{ pay }}</strong>元</span> </div> </div> <div class="distance"> <div class="time" id="distance"> <span v-if="haveBus">距 <strong id="dis_num">{{siteNum}}</strong> 站</span> <span v-else>暂无车辆</span> </div> <span class="arr">到达</span> <span class="next_site">{{text}}</span> </div> </div> <div class="site_list"> <div class="wapper_sitelist"> <ul class="road" :style="{width: listWidth + 'rem'}"> <li class='part' v-for="(item, index) in siteList" @click="showActive(index, item.siteName)"> <span class="dot_p" :class="{'dot_show': ind === index}"></span> <span class='dot_r'></span> <div class='name'> <span class='dot_d ' :class="{'dot_d_show': ind === index}"></span> <span class='text ' :class="{'text_show': ind === index}">{{item.siteName}}</span> </div> </li> </ul> <div class="bus_road" :style="backImage"></div> </div> <div id="gotomap" class="button" style="right:1.24rem"> <img src="../assets/line/map.png" /> <span>地图</span> </div> <div class="button" style="right:0.3rem" @click="changeDirect"> <img src="../assets/line/change3.png" /> <span>换向</span> </div> </div> </div> </template> <script> import AMap from 'AMap' export default { name: 'simpleMap', data () { return { siteId: this.$route.query.siteId, lineName: this.$route.query.lineName, siteName: this.$route.query.siteName, siteList: [], time_s: '', time_e: '', from: '', busPosition: [2, 5, 11], to: '', lineInfo: [], listWidth: '', isActive: false, pay: '', ind: '', text: this.$route.query.siteName, lineId: '', backImage: { backgroundImage: 'url(' + require('../assets/line/bus.png') + '),url(' + require('../assets/line/bus.png') + '),url(' + require('../assets/line/bus.png') + ')', backgroundPosition: '2rem,5rem,11rem', width: '' }, siteNum: '0', haveBus: true } }, mounted: function () { AMap.service(['AMap.LineSearch'], function () { var linesearch = new AMap.LineSearch({ pageIndex: 1, city: this.city, pageSize: 20, extensions: 'all' // 返回全部信息 }) linesearch.search(this.lineName, function (status, result) { // 取回公交路线查询结果 if (status === 'complete' && result.info === 'OK') { this.lineInfo = result.lineInfo var tips = result.lineInfo[0] console.log(tips) this.from = tips.start_stop + '-' this.to = tips.end_stop this.lineId = tips.id if (tips.stime.length !== 0 && tips.length !== 0) { this.time_s = tips.stime.substr(0, 2) + ':' + tips.stime.substr(2, 2) this.time_e = tips.etime.substr(0, 2) + ':' + tips.etime.substr(2, 2) } else { this.time_s = '05:40' this.time_e = '18:40' } this.pay = tips.basic_price this.listWidth = tips.via_stops.length this.backImage.width = tips.via_stops.length + 'rem' tips.via_stops.forEach((item, index) => { if (item.id === this.siteId) { this.ind = index console.log(index) this.showActive(this.ind, this.siteName) } this.siteList.push({ siteName: item.name, siteLat: item.location.lat, siteLng: item.location.lng }) }) } else { // 无数据或者查询失败 } // setInterval(busposition(), 60000) }.bind(this)) }.bind(this)) }, methods: { showActive: function (index, siteName) { this.ind = index this.text = siteName var TF = false for (let i = 0; i <= this.busPosition.length; i++) { if (index + 1 > this.busPosition[i]) { this.haveBus = true this.siteNum = index + 1 - this.busPosition[i] TF = true } } if (TF === false) { this.haveBus = false } }, changeDirect: function () { for (let i = 0; i < this.lineInfo.length; i++) { console.log(this.lineInfo[i].name.substr(0, this.lineInfo[i].name.indexOf('('))) if (this.lineInfo[i].id !== this.lineId && this.lineName === this.lineInfo[i].name.substr(0, this.lineInfo[i].name.indexOf('('))) { var tips = this.lineInfo[i] console.log(tips) this.siteList = [] this.from = tips.start_stop + '-' this.to = tips.end_stop this.lineId = tips.id if (tips.stime.length !== 0 && tips.length !== 0) { this.time_s = tips.stime.substr(0, 2) + ':' + tips.stime.substr(2, 2) this.time_e = tips.etime.substr(0, 2) + ':' + tips.etime.substr(2, 2) } else { this.time_s = '05:40' this.time_e = '18:40' } this.pay = tips.basic_price this.listWidth = tips.via_stops.length tips.via_stops.forEach((item, index) => { if (item.id === this.siteId) { this.ind = index this.showActive(this.ind, this.siteName) console.log(index) } this.siteList.push({ siteName: item.name, siteLat: item.location.lat, siteLng: item.location.lng }) }) break } } } } } </script> <style scoped> .info_wapper { height: 3.12rem; background: #36A3F9; padding: 0.3rem; } .info_wapper .info {} .info_wapper .site { font-size: 0.32rem; color: #fff; margin-bottom: 0.2rem; text-align: left; } .info_wapper .site span { width: 40%; white-space: nowrap; text-overflow: ellipsis; } .info_wapper .from { padding-left: 0.52rem; background: url(../assets/line/position2.png) no-repeat left; background-size: 0.28rem 0.32rem; } .info_wapper .tit { color: #fff; font-size: 0.26rem; padding-left: 0.52rem; margin-bottom: 0.2rem; height: 0.42rem; } .info_wapper .tit span { float: left; margin-right: 0.3rem; } .info_wapper .distance { height: 1.3rem; background: #fff; border-radius: 0.08rem; font-size: 0rem; color: #B7BABB; line-height: 1.3rem; text-align: center; } .info_wapper .time { float: left; width: 40%; font-size: 0.26rem; height: 1.3rem; line-height: 1.3rem; } .info_wapper .time strong { font-size: 0.32rem; color: #353738; } .info_wapper .arr { float: left; width: 20%; font-size: 0.26rem; } .info_wapper .next_site { width: 40%; font-size: 0.32rem; color: #353738; text-overflow: ellipsis; line-height: 0.4rem; display: inline-block; vertical-align: middle; } /*站点列表*/ .site_list { width: 100%; height: 100%; position: relative; padding-top: 1.64rem; } .site_list .button { width: 0.64rem; height: 0.64rem; border-radius: 50%; background: #fff; position: absolute; top: 0.4rem; font-size: 0.12rem; color: #36A3F9; line-height: 0.34rem; text-align: center; } .site_list .bus_road { height: 0.28rem; background-repeat: no-repeat; background-size: 0.48rem 0.24rem; position: absolute; top: 0.3rem; left: 0; z-index: 1001; } .site_list .button span { font-size: 0.24rem; transform: scale(0.7); display: block; } .site_list .button img { width: 0.24rem; display: block; margin: 0 auto; margin-top: 0.05rem; } .site_list .wapper_sitelist { width: 100%; overflow-x: scroll; position: relative; -webkit-overflow-scrolling: touch; } .wapper_sitelist::-webkit-scrollbar { display: none; } .site_list .road {} .site_list .part { width: 1rem; float: left; } .site_list .dot_p { width: 1rem; height: 0.36rem; display: block; } .site_list .dot_show { background: url(../assets/line/position_red.png) no-repeat center; background-size: 0.28rem 0.36rem; } .site_list .dot_r { width: 1rem; height: 0.2rem; background: url(../assets/line/road.png) no-repeat center; background-size: 100%; margin-top: 0.1rem; display: block; } .site_list .name { width: 0.36rem; margin: auto; } .site_list .dot_d { width: 0.12rem; height: 0.12rem; border-radius: 50%; background: #B3B3B3; margin-top: 0.1rem; margin-right: 0.12rem; display: block; float: right; } .site_list .dot_d_show { background: #F0585D; } .site_list .text_show { color: #F0585D; } .site_list .text { font-size: 0.32rem; width: 0.36rem; margin-top: 0.2rem; float: right; } </style>
06-25
uniapp 怎么设置锚点 多个元素设置锚点,当滚动到某个锚点时,标记该锚点<u-row align="top" gutter="0" style="width: 100%;"> <u-col span="3"> <scroll-view scroll-y="true" class="sh_aside"> <view class="aside-item flex-fsfs" v-for="(item,i) in categories" :key="i" @tap="selectCategory(item)"> <text :class="['nomal-line',item.code==cateVal? 'active-line':'']"></text> <text :class="['nomal-desc',item.code==cateVal? 'active-desc':'']">{{item.name}}</text> </view> <view class="empty" style="padding-top: 20vh;" v-if="categories.length == 0"> 暂无分类 </view> </scroll-view> </u-col> <u-col span="9" > <view class="sh_main"> <view class="drop-box"> <u-dropdown> <u-dropdown-item active-color="#3296FA" inactive-color="#666666" height="500" :options="nutrients" v-model="nutVal" :title="crtNutrient.label" @change="dropdownChange"></u-dropdown-item> </u-dropdown> </view> <scroll-view scroll-y="true" class="sh_artcle" :scroll-into-view="crtView" > <view class="part" v-for="item,index in ingredientList" :key="index" :id="item.customId"> <view class="part-title"> {{item.name}} </view> <view class="flex-fsc part-list" v-for="sc,i in item.list" :key="i"> <image src="/static/images/manbing/recipes_sc_mrbj.png" mode="aspectFill" style="width: 83rpx;height: 83rpx;"></image> <view class=""> <view class=""> {{sc.name}} </view> <view class="part-text"> 营养元素 </view> </view> </view> <view class="empty" v-if="item.list.length == 0"> 暂无数据 </view> </view> <view class="empty" style="padding-top: 20vh;" v-if="ingredientList.length == 0"> 暂无数据 </view> </scroll-view> </view> </u-col> </u-row>
03-26
<template> <view class="wapper"> <!-- <view class="bg-image"></view> --> <image class="bg-image" src="/static/home/bus/bg-image.png" mode="widthFix" style="width: 100%;" /> <!-- 自定义导航栏 --> <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }"> <view class="navbar-content"> <!-- 左侧返回按钮 --> <view class="back-btn" @click="handleBack"> <image src="/static/home/bus/back-icon.png" mode="aspectFit" style="width: 48rpx;height: 48rpx;" /> </view> <!-- 中间标题 --> <text class="title">{{busLineBase.name}}</text> </view> </view> <view class="wapper-content" :style="{ paddingTop: statusBarHeight +50 + 'px' }"> <view class="line_info"> <view class="site"> <text class="from">{{busLineBase.startSn}}</text> <view class="arrow"> <text class="to">{{busLineBase.endSn}}</text> </view> </view> <view class="tit"> <view class="time_s"> <text class="time-text">{{busLineBase.firstTime}}</text> </view> <view class="time_e"> <text class="time-text">{{busLineBase.lastTime}}</text> </view> <text class="price">票价: {{busLineBase.price}}</text> </view> </view> <view class="distance-class"> <view class="station"> <view class="station-title"> <view class="station-name">候车站</view> <view class="station-content"> <view class="active">{{stationName}}</view> <view class="underline"></view> </view> </view> </view> <view class="distance" v-if="state==0 && travelOrder!=0"> <view class="time"> <text class="time_title">{{Math.ceil(travelTime/60)}}分钟</text> </view> <text class="arr">{{travelOrder}}站/ <text v-if="travelDistance<1000">{{numFilter(travelDistance)}}m</text> <text v-else>{{numFilter(travelDistance/1000)}}km</text> </text> </view> <view class="distance" v-else-if="state==0 && travelOrder==0 && isArrive==1"> <view class="time"> <view class="bus-arr">已到站</view> </view> </view> <view class="distance" v-else-if="state==0 &&isArrive==0"> <view class="time"> <view class="bus-coming">即将到站 {{travelDistance}}m</view> </view> </view> <view class="distance" v-else-if="state==-1"> <view class="time"> <view class="none">等待发车</view> </view> </view> <view class="distance" v-else> <view class="time"> <view class="none">暂无车辆信息</view> </view> </view> <!-- <view>已到站</view> --> </view> </view> <view class="site_list"> <scroll-view class="wapper_sitelist" scroll-x="true" scroll-with-animation :scroll-into-view="targetId"> <view class="road"> <view class='part' v-for="(item, index) in siteList" @click="showActive(index, item.sn)"> <view :id="'id'+item.sid" class='name'> <view> <view class="dot_p" :class="{'dot_p_show': ind === index}"></view> <view class='dot_r' v-if="index!=siteList.length-1"></view> </view> <div :class="item.state==1?'road-bus':'road-bus-coming'" v-if="item.isHaveBus==0"></div> <view class='dot_d' :class="{'dot_d_show': ind === index}"></view> <view class='text' :class="{'text_show': ind === index}"> <view>{{index +1}}</view> <view class="text-dir"> {{item.sn}} </view> </view> </view> </view> </view> </scroll-view> <!-- <view class="my-map"></view> --> </view> <view class="my-map"> 223123 <web-view ref="webview" :webview-styles="webviewStyles" :src="src" @onPostMessage="getMessage"></web-view> </view> </view> </template> <script> import { getRealTimeBusLine, getRealTimeBusLineStation } from '@/request/bus.js' export default { data() { return { src: '', timer: null, isArrive: 0, targetId: '', state: 0, stationName: '', travelDistance: 0, travelTime: 0, travelOrder: 0, ratio: '', ind: '', siteId: "", lineName: "二号线", siteName: "动漫园站", siteList: [], busLineBase: [], stateBus: [], time_s: '', time_e: '', from: '', busPosition: [0, 5, 11], to: '', isActive: false, lineId: '', siteNum: '0', haveBus: true, webviewStyles: { position: 'absolute', top: '850px', bottom: '30px', // zIndex: '999', marginTop: '850px', marginLeft: '20px', marginRight: '20px', marginBottom: '10px', height: '500px' } // 保留原有数据项... } }, onLoad(options) { // 获取路由参数 const { statusBarHeight } = uni.getSystemInfoSync() // const systemInfo = uni.getSystemInfoSync(); // this.ratio = (systemInfo.windowWidth / 750) / 0.5 console.log("options", options) this.statusBarHeight = statusBarHeight this.lineId = options.lineId this.lat = options.lat this.lng = options.lng this.lineName = options.lineName this.getLineDetail() if (this.timer) { clearInterval(this.timer); this.timer = null; } // this.timer = setInterval(() => { // console.log("30") // this.refresh() // }, 1000 * 30); this.init() }, methods: { init() { setTimeout(() => { this.src = '../../../../hybrid/html/map.html' }, 1000); }, handlePostMessage(res) { this.$refs.webview.evalJs(`handleMessage()`); }, getMessage(e) { uni.showModal({ content: "111", showCancel: false }) }, numFilter(value) { if (value != 0) { // 将数值转换为浮点数,并保留两位小数 let realVal = parseFloat(value).toFixed(2); return realVal; } }, async getLineDetail() { var res = await getRealTimeBusLine({ lineId: this.lineId, lat: this.lat, lng: this.lng }) if (res.code == 0) { console.log("1", res) this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.ind = res.data.targetOrder - 1 this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this.targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.siteList = this.processArrays(this.siteList, this.stateBus, 'order', 'state'); } } } }, async showActive(index, siteName) { this.ind = index this.stationName = siteName var res = await getRealTimeBusLineStation({ lineId: this.lineId, stationName: this.stationName }) if (res.code == 0) { this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.ind = res.data.targetOrder - 1 this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this.targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.isArrive = this.distance[0].state this.siteList = this.processArrays(this.siteList, this.stateBus, 'order', 'state'); } } } }, handleBack() { uni.navigateBack() }, async refresh() { console.log("刷新") var res = await getRealTimeBusLineStation({ lineId: this.lineId, stationName: this.stationName }) if (res.code == 0) { this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.ind = res.data.targetOrder - 1 this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this .targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.isArrive = this.distance[0].state this.siteList = this.processArrays(this.siteList, this .stateBus, 'order', 'state'); } } } }, // 找到距离最近车站的小车 findAllClosest(arr, target) { const validItems = arr.filter(item => item.order < target + 1); if (validItems.length === 0) return []; const distances = validItems.map(item => ({ item, distance: Math.abs(item.order - target) })); if (distances.length != 0) { const minDist = Math.min(...distances.map(d => d.distance)); return distances.filter(d => d.distance === minDist).map(d => d.item); } }, processArrays(arrayA, arrayB, key, valueKey) { // 创建arrayB的快速查找映射(基于指定键) const bMap = new Map(); arrayB.forEach(item => { if (item[key] !== undefined) { bMap.set(item[key], item); } }); // 遍历arrayA并添加属性 return arrayA.map(itemA => { // 浅拷贝避免修改原对象 const newItem = { ...itemA }; // 检查是否存在匹配元素 if (bMap.has(newItem[key])) { const matchedB = bMap.get(newItem[key]); // newItem.state = 0; newItem.isHaveBus = 0; // 添加arrayB中的属性值(如果存在) if (matchedB[valueKey] !== undefined) { newItem[valueKey] = matchedB[valueKey]; } } return newItem; }); } }, onPullDownRefresh() { console.log("下拉") this.refresh() setTimeout(() => { //结束下拉刷新 uni.stopPullDownRefresh(); }, 1000); }, onUnload() { console.log('页面即将卸载'); if (this.timer) { clearInterval(this.timer); this.timer = null; } } } </script> <style> page { background-color: #f5f5f5; } </style> <style scoped> .bg-image { position: absolute; } .custom-navbar { position: absolute; top: 0; left: 0; width: 100%; z-index: 1000; /* 自定义背景色 */ /* 自定义阴影 */ } .navbar-content { height: 44px; /* 标准导航栏高度 */ display: flex; align-items: center; padding: 0 15px; } .title { flex: 1; text-align: center; font-size: 17px; font-weight: bold; color: #333; /* 标题颜色 */ } .back-btn { width: 48rpx; height: 48rpx; } .right-area { width: 40px; text-align: right; } .info_wapper { height: 156px; /* background: #36A3F9; */ /* background: url(@/static/home/bus/detail-bg.png) left no-repeat; */ padding: 15px; color: black; position: absolute; z-index: 9; width: 100%; } .line_info { position: relative; /* display: flex; */ } .site { font-size: 32rpx; color: black; margin-bottom: 10px; text-align: left; display: flex; margin-left: 30px; } .from { /* padding-left: 52rpx; */ color: black; } .arrow { background: url(@/static/home/bus/single.png) left no-repeat; background-size: 14px 5px; margin-left: 10px; color: black; } .to { padding-left: 26px; color: black; } .time_s { background: url(@/static/home/bus/start.png) left no-repeat; background-size: 18px 18px; justify-self: baseline; } .time_e { background: url(@/static/home/bus/end.png) left no-repeat; background-size: 18px 18px; margin-left: 15px; } .price { margin-left: 15px; } .tit { color: #fff; font-size: 26rpx; /* padding-left: 52rpx; */ margin-bottom: 10px; height: 21px; color: #333; display: flex; align-items: baseline; margin-left: 30px; } .distance-class { border-radius: 15px; /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background: url(@/static/home/bus/distance-bg.png) center no-repeat; background-size: cover; height: 160px; position: absolute; z-index: 99; left: 20px; right: 20px; } .distance { color: #B7BABB; line-height: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 99; /* align-items: baseline; */ } .time { color: aquamarine; } .bus-arr { color: rgb(255, 164, 17); font-weight: bold; margin-top: 10px; } .bus-coming { color: rgb(55, 170, 126); font-weight: bold; margin-top: 10px; } .station { margin-left: 20px; color: #353738; padding: 10px; } .station-title { display: flex; align-items: baseline; } .station-name { margin-right: 15px; } .station-content { padding-top: 10px; /* padding-left: 20rpx; */ position: relative; /* padding-right: 50rpx; */ /* 确保文字在下划线上方 */ z-index: 2; justify-content: center; display: flex; align-items: center; /* 文字在上层 */ } .underline { position: absolute; bottom: 2px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ border-radius: 3px; z-index: -1; width: 80%; align-items: center; justify-content: center; display: flex; /* margin-left: 30rpx; */ /* width: 60rpx; */ /* 下划线在文字下方 */ } .active { color: black; /* 激活状态文字颜色 */ font-weight: bold; /* font-size: 36rpx; */ } .time { float: left; width: 40%; font-size: 26rpx; /* height: 130rpx; */ line-height: 40px; } .time { font-size: 36rpx; color: #353738; } .time-text { margin-left: 25px; } .time_title { color: rgb(14, 170, 112); font-weight: bold; } .arr { float: left; /* width: 20%; */ font-size: 30rpx; color: rgb(14, 170, 112); } .site_list { /* margin: 15px; */ /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background-color: white; border-radius: 15px; margin-top: 150px; padding-left: 15px; padding-right: 15px; padding-top: 15px; padding-bottom: 10px; background: url(@/static/home/bus/site-bg.png) center no-repeat; position: absolute; z-index: 99; left: 20px; right: 20px; background-size: cover; /* 让背景图片覆盖整个视口 */ } .site_list .wapper_sitelist { width: 100%; overflow-x: scroll; position: relative; -webkit-overflow-scrolling: touch; display: flex; } .bus_road { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: 4px; left: 14px; /* margin-top: -40px; */ } .road-bus { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: -35px; margin-left: 10px; /* left: 14px; */ /* margin-top: -40px; */ } .road-bus-coming { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: -35px; margin-left: -40px; } .road { display: flex; } .wapper_sitelist::-webkit-scrollbar { display: none; } /deep/::-webkit-scrollbar { display: none; width: 0; height: 0; } .part { padding: 10px; display: flex; flex-direction: row; text-align: center; justify-content: center; padding-top: 30px; } .site_list .dot_r { margin-top: 25px; position: absolute; top: 23px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ width: 46px; border-radius: 3rpx; z-index: 1; margin-left: 4px; align-items: center; justify-content: center; display: flex; } .site_list .name { margin-top: 28px; display: flex; flex-direction: column; align-items: center; } .site_list .text { display: flex; text-align: center; margin-left: 5px; flex-direction: column; } .site_list .text_show { display: flex; text-align: center; margin-left: 5px; color: rgb(14, 170, 112); font-weight: bold; } .site_list .dot_show { background: url(@/static/home/bus/position_red.png) no-repeat center; background-size: 14px 18px; } .site_list .dot_d_show { border-radius: 50%; width: 16px; height: 16px; background-color: rgba(110, 207, 169, 0.5); position: absolute; z-index: 999; top: 41px; margin-left: 8px; display: flex; align-items: center; justify-content: center; } .road-class { display: flex; } .dot_p { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(110, 207, 169); position: absolute; z-index: 999; top: 45px; display: flex; align-items: center; justify-content: center; /* margin-right: 2px; */ /* margin-left: 10rpx; */ } .dot_p_show { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(14, 170, 112); position: absolute; z-index: 999; top: 45px; display: flex; align-items: center; justify-content: center; } .text-dir { margin-top: 5px; writing-mode: vertical-rl; letter-spacing: 3px; } .none { color: #848484; font-size: 16px; margin-top: 15px; } .my-map { /* width: 100%; */ position: absolute; z-index: 999; /* bottom: 20px; */ /* background-color: white; */ /* margin-bottom: 50px; */ left: 0; right: 0; top: 650px; margin: 20px; height: 370px; } .map { margin-top: 500px; margin-left: 20px; margin-right: 20px; margin-bottom: 10px; /* z-index: 9999; */ } </style> 将uniapp写法转化为h5
最新发布
07-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值