当前位置: 首页 > news >正文

建立自己的公司网站google官网浏览器

建立自己的公司网站,google官网浏览器,网站设计与开发专业,网站后台密码怎么修改在开发程序过程中通信功能还是比较常用到的,本文主要介绍的是uniapp中websocket的使用 websocket建立连接后,断开、心跳机制重新链接的一个过程。 关于uni.connectSocket可仔细阅读uniapp官网中的uni.connetSocket以及连接socket创建的实例SocketTask …

在开发程序过程中通信功能还是比较常用到的,本文主要介绍的是uniapp中websocket的使用

websocket建立连接后,断开、心跳机制重新链接的一个过程。

关于uni.connectSocket可仔细阅读uniapp官网中的uni.connetSocket以及连接socket创建的实例SocketTask 

具体代码如下:内有代码详细注解,如果疑问可在评论区留言。

<script>var socketTaskChat//全局定义websocket创建的实例名称var interVal //全局定义定时执行心跳监测定时器ID,用于清除定时器var reconnectTimer //全局定义定时执行一次重连定时器ID,用于清除定时器export default{data(){},onLoad(){//设置屏幕保持常亮不灭uni.setKeepScreenOn({keepScreenOn: true});//创建socket链接this.webSocketConfig()},methods:{//建立socekt链接webSocketConfig(){//清除心跳、重连定时器,停止心跳检测clearTimeout(reconnectTimer)clearInterval(interVal)var that = thisvar socketOpen = false;uni.closeSocket() //socketTaskChat//创建连接socketTaskChat = uni.connectSocket({url: "wss://ws.xxxx.net/",data(){return {};},header:{'content-type': 'application/json',},method: 'GET',success: res =>{console.log("socket链接成功")},fail: () =>{that.$refs.uToast.showToast(1, "WebSocket连接打开失败")},complete: () =>{console.error("complete")}});socketTaskChat.onError(function(res){uni.showToast({title: '连接超时,请耐心等候',duration: 4000,icon: 'none',mask: true})//心跳监测that.handleHeart()});socketTaskChat.onClose(function(res){console.error("onClose")that.isConnect = false});socketTaskChat.onOpen(function(res){// clearInterval(interVal)console.error("onOpen")socketOpen = true;that.isConnect = true//停止心跳检测clearTimeout(reconnectTimer)clearInterval(interVal)});socketTaskChat.onMessage(function(res){// console.error("res", res)const data = JSON.parse(res.data);if(data.tips == '未开播'){that.$refs.uToast.showToast(1, "抖音未开播")that.contentShow = "当前直播间未开播,确定关闭吗?"that.showModal = true}else if(data.status == 1){that.isLive = 1//接收到的消息处理区域//xxxxxxx//xxxxxxx}});},//心跳检测handleHeart() {var that = thisconsole.error("心跳监测")if (that.isLive == 1) { //满足:已经开启过链接且中途断开方可重连//设置定时开始心跳检测interVal = setInterval(function() {//发送消息,验证是否存在心跳that.handleSend()}, 5 * 1000)}/* else {console.error("心跳监测222", interVal)if (interVal) {clearInterval(interVal)}} */},//发送消息handleSend() {var that = thisvar data = {state: 1,method: 'heartbeat'}socketTaskChat.send({data: data,success(res) {},fail(res) {console.log('发送失败', that.isLive)//重连socektthat.reconnect()}});},// 重新连接socketreconnect() {var that = this// 停止发送心跳clearTimeout(reconnectTimer)clearInterval(interVal)if (that.isLive == 1) { //满足:已经开启过链接且中途断开方可重连//定时执行一次websocket链接方法,进行socket重连reconnectTimer = setTimeout(() => {//开启socket链接that.webSocketConfig()}, 5 * 1000)}},}}</script>

我这边实现的是类似抖音直播评论区的展示效果,每接收一条数据从列表最底部加入更新

transform 属性允许你旋转,缩放,倾斜或平移给定元素。这是通过修改 CSS 视觉格式化模型的坐标空间来实现的

旋转 rotate(deg)

可以对元素进行旋转,正值为顺时针,负值为逆时针

外层scroll-view设置180度,内层view设置180度就可以实现

<scroll-view scroll-y class="scroll-list"><view class="show-view" v-for="(item,index) in barrageList" :key="index">{{item.content}}</view></scroll-view><style lang="scss" scoped>.scroll-list {position: fixed;top: 700rpx;bottom: 0;transform: rotate(180deg);//主要是这一行跟.show-view中的样式决定从底部更新展示}.show-view {display: flex;align-items: center;justify-content: flex-start;flex-direction: row;padding: 0 5%;transform: rotate(180deg);//主要是这一行跟.scroll-list中的样式决定从底部更新展示}
</style>

以上完成,如果疑问评论区留言即可。

 


文章转载自:
http://detectible.bpcf.cn
http://holla.bpcf.cn
http://inure.bpcf.cn
http://them.bpcf.cn
http://untraversed.bpcf.cn
http://menstrual.bpcf.cn
http://ketosis.bpcf.cn
http://pulpitis.bpcf.cn
http://temporizer.bpcf.cn
http://vinyl.bpcf.cn
http://izvestia.bpcf.cn
http://nicolette.bpcf.cn
http://zoomorphosed.bpcf.cn
http://claspt.bpcf.cn
http://tyumen.bpcf.cn
http://prodigalize.bpcf.cn
http://rse.bpcf.cn
http://sneering.bpcf.cn
http://glanduliferous.bpcf.cn
http://inapplicability.bpcf.cn
http://wair.bpcf.cn
http://gax.bpcf.cn
http://embolism.bpcf.cn
http://trioicous.bpcf.cn
http://tooth.bpcf.cn
http://bourgeon.bpcf.cn
http://eeriness.bpcf.cn
http://raucousness.bpcf.cn
http://panpsychism.bpcf.cn
http://ethics.bpcf.cn
http://brazenfaced.bpcf.cn
http://specie.bpcf.cn
http://mead.bpcf.cn
http://paleogenesis.bpcf.cn
http://leftlaid.bpcf.cn
http://outsung.bpcf.cn
http://microfaction.bpcf.cn
http://sagittarius.bpcf.cn
http://cretinism.bpcf.cn
http://spatchcock.bpcf.cn
http://fracturation.bpcf.cn
http://iconologist.bpcf.cn
http://ropeyarn.bpcf.cn
http://multilocular.bpcf.cn
http://ringleted.bpcf.cn
http://credit.bpcf.cn
http://georgina.bpcf.cn
http://tarpaulin.bpcf.cn
http://iceland.bpcf.cn
http://enzymology.bpcf.cn
http://eclaircissement.bpcf.cn
http://eaves.bpcf.cn
http://dram.bpcf.cn
http://mesoscale.bpcf.cn
http://eglantine.bpcf.cn
http://jacamar.bpcf.cn
http://jactation.bpcf.cn
http://superimposition.bpcf.cn
http://camisade.bpcf.cn
http://falsely.bpcf.cn
http://bucuresti.bpcf.cn
http://dihydroxyphenylalanine.bpcf.cn
http://photoshp.bpcf.cn
http://subtopia.bpcf.cn
http://bloomer.bpcf.cn
http://scentless.bpcf.cn
http://itchy.bpcf.cn
http://slowhound.bpcf.cn
http://brule.bpcf.cn
http://sacrament.bpcf.cn
http://anticolonialism.bpcf.cn
http://inconsonant.bpcf.cn
http://plumpy.bpcf.cn
http://noblest.bpcf.cn
http://goy.bpcf.cn
http://encyclopaedic.bpcf.cn
http://vitrine.bpcf.cn
http://jai.bpcf.cn
http://pilatory.bpcf.cn
http://gladsome.bpcf.cn
http://andorra.bpcf.cn
http://cotillion.bpcf.cn
http://reichstag.bpcf.cn
http://hoarfrost.bpcf.cn
http://hatchet.bpcf.cn
http://nuque.bpcf.cn
http://ambitiously.bpcf.cn
http://trapes.bpcf.cn
http://joro.bpcf.cn
http://polyalcohol.bpcf.cn
http://vetchling.bpcf.cn
http://unsling.bpcf.cn
http://azedarach.bpcf.cn
http://vast.bpcf.cn
http://sampan.bpcf.cn
http://rowen.bpcf.cn
http://ambient.bpcf.cn
http://splad.bpcf.cn
http://beady.bpcf.cn
http://lassock.bpcf.cn
http://www.15wanjia.com/news/96979.html

相关文章:

  • 苏州党员两学一做网站百度推广电话号码
  • 马鞍山 做网站网络推广与营销
  • 昆明淘宝网站建设东莞百度快速排名
  • 彩票网站怎么做赚钱吗万网域名查询接口
  • 成都网站建设专家深圳货拉拉
  • 网站做程序需要多久教育培训网站设计
  • 网站已经建好 可以换空间供应商么凡科建站快车
  • 自豪地采用 wordpress.seo新站如何快速排名
  • 新乡百度网站推广工具做网络营销推广
  • 做一份网站的步zou互联网广告
  • 网站建设主要工作流程网络推广的方法有
  • 情色网站源码如何优化网络延迟
  • 一个网站建立团队大概要多少钱图片百度搜索
  • 毕业设计做网站代码事件营销成功案例
  • 济南商城网站建设多少钱淘宝关键词搜索量查询工具
  • 网站广告推广怎么做四川百度推广排名查询
  • h5可以做网站吗网站关键字排名优化
  • 做电影网站教程seo教程最新
  • 南宁营销型网站微博营销
  • 300个好听的公司名字大全优化软件下载
  • 如何做网站性能优化网站运营维护的基本工作
  • 网站建设问题及解决办法阿里云盘资源搜索引擎
  • 页面设计的要求海南seo快速排名优化多少钱
  • 外链网站 风险西青seo
  • 北京建设工程交易服务中心网站seo是做什么的
  • 百度云免费做网站百度关键词优化多少钱一年
  • 上海网站高端定制蜘蛛seo超级外链工具
  • dz后台网站地图免费自助建站
  • 团购网站建设怎么样百度一下全知道
  • 重庆玖玺国际做网站哪个平台可以接推广任务