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

青岛网站设计建设云浮哪有做网站公司

青岛网站设计建设,云浮哪有做网站公司,wordpress静用字体,简单的wordpress模板下载uniapp实现全局悬浮框(按钮,页面,图片自行设置) 可拖动 话不多说直接上干货 1,在components新建组件(省去了每个页面都要引用组件的麻烦) 2,实现代码 <template><view class"call-plate" :style"top: top px;left: left px;" touchmove&quo…

uniapp实现全局悬浮框(按钮,页面,图片自行设置) 可拖动
话不多说直接上干货
1,在components新建组件(省去了每个页面都要引用组件的麻烦)
在这里插入图片描述
2,实现代码

<template><view class="call-plate" :style="'top:' + top + 'px;left:' + left + 'px;'" @touchmove="touchmove" @touchend="touchend" @touchstart="touchstart" v-if="popupShow">通话中悬浮框</view>
</template><script>export default {name: "call-screen",emits: ["hide", "confirm"],props: {/*** 默认号码*/number: {type: String,default: ""}},data() {return {popupShow: true, // 是否显示当前页面top: 0,left: 0,startTop: 0,startLeft: 0,startClientTop: 0,startClientLeft: 0,}},watch: {},computed: {i18n() {return this.$t}},created() {let that = thisthis.popupShow = getApp().globalData.callShowthis.top = getApp().globalData.callShowTop // 获取全局存储的位置,也可以使用本地缓存存储this.left = getApp().globalData.callShowLeftuni.$on(getApp().globalData.$global.CALL_SHOW_UPDATE, this.callShowUpdate)uni.$on(getApp().globalData.$global.CALL_SHOW_OPEN, this.callShowOpen)uni.$on(getApp().globalData.$global.CALL_SHOW_CLOSE, this.callShowClose)},destroyed() {// 销毁通知uni.$off(getApp().globalData.$global.CALL_SHOW_UPDATE, this.callShowUpdate)uni.$off(getApp().globalData.$global.CALL_SHOW_OPEN, this.callShowOpen)uni.$off(getApp().globalData.$global.CALL_SHOW_CLOSE, this.callShowClose)},methods: {touchmove(e) {// 单指触摸if (e.touches.length !== 1) {return false;}// console.log(e)this.top = e.changedTouches[0].pageY - this.startClientTop + this.startTopthis.left = e.changedTouches[0].pageX - this.startClientLeft + this.startLeft},touchend(e) {// console.log("------结束,top:" + this.top + ",left:" + this.left)// console.log(e)getApp().globalData.callShowTop = this.topgetApp().globalData.callShowLeft = this.leftuni.$emit(getApp().globalData.$global.CALL_SHOW_UPDATE) // 更新每个页面悬浮框位置},touchstart(e) {// console.log("------开始")// console.log(e)this.startTop = this.topthis.startLeft = this.leftthis.startClientTop = e.changedTouches[0].pageYthis.startClientLeft = e.changedTouches[0].pageX},callShowUpdate() {// 更新每个页面悬浮框位置this.top = getApp().globalData.callShowTopthis.left = getApp().globalData.callShowLeft},callShowOpen() {// 打开每个页面悬浮框this.popupShow = truegetApp().globalData.callShow = true},callShowClose() {// 关闭每个页面悬浮框this.popupShow = falsegetApp().globalData.callShow = false},}}
</script><style lang="scss" scoped>.call-plate {display: flex;position: absolute;width: 90px;height: 160px;z-index: 9999999;background-color: yellow;}
</style>
在 App.vue中全局存储悬浮框位置信息
globalData: {callShowTop: 100, // 悬浮框topcallShowLeft: 100, // 悬浮框leftcallShow: false, // 悬浮框是否显示
},

3,在每个需要用到悬浮框的页面引入

<template><view class="content"><!--组件引用--><call-screen></call-screen></view>
</template>
发通知控制显示隐藏悬浮框
uni.$emit(that.global.CALL_SHOW_CLOSE)
uni.$emit(that.global.CALL_SHOW_OPEN)

4,实现效果
请添加图片描述
每个页面切换后都会更新最新位置

http://www.yayakq.cn/news/260866/

相关文章:

  • 做同城服务网站比较成功的网站那个网站做外贸
  • 自助提卡网站怎么做网站备案后内容
  • 企业建设网站对客户的好处成功备案的网站增加域名
  • 成都网站建设新网创想哦咪咖网站建设
  • 电子商务网站建设(论文如何建设商城网站
  • 天津宁河区建设网站网站建设大致步骤
  • 那个网站平台可以做兼职叮当快药网站谁做的
  • 山西网站建设服务好开发板的用途
  • 微信公众号端网站开发网站公司怎么做
  • 可以显示一张图片的网站怎么搭建免费咨询律师网站
  • 网站建设结课总结如何做好线上营销
  • 深圳住建局官方网站工业设计产品设计案例
  • 《php网站开发》课程资料永久免费网站
  • 网络广告投放网站湖北外贸网站设计制作
  • 关键词网站建设优化网站备案安全责任书是谁盖章
  • 内黄县建设局网站网站建设需要哪些费用支出
  • 空间商网站ip被攻击后换ip中企动力z云邮企业邮箱登录
  • 外贸社交网站排名网站开发与维护就业前景
  • 做队徽的网站云服务器是虚拟技术吗
  • 成都网站建设制作推广下载app
  • 单页网站怎么制作教程徐州自助建站软件
  • 国外简洁的网站德阳做网站公司
  • 广州建站商城推广app下载
  • 卓航网站开发班级优化大师怎么加入班级
  • 上海网站建设 公司案例企业年报入口官网查询系统
  • 木材板材网站制作方案上海建筑设计院停工停产通知
  • 做网站的方法及措施北京个人注册公司流程和费用
  • photoshop制作网站阿里云建设wordpress
  • 湖北平台网站建设哪家好高级又小众的公众号
  • 聊城网站优化信息提供郑州网站建设