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

uni-app:实现页面效果1

效果

代码

<template><view><view class="add"><image :src="add_icon" mode=""></image></view><view class="container_position"><view class="container_info"><view class="position"><view class="circle"><img :src="device" class="center-image"><view v-for="(item, index) in itemList" :key="index" class="item" :style="getItemStyle(index)"><img :src="item.src" /><view>{{ item.name }}</view></view></view></view></view></view></view>
</template><script>export default {data() {return {device: getApp().globalData.icon + 'look/device.png',add_icon: getApp().globalData.icon + 'look/add.png',itemList: [{name: "车道指示器",src: "/static/item2.png"},{name: "车道指示器",src: "/static/item3.png"},{name: "车道指示器",src: "/static/item4.png"},{name: "车道指示器",src: "/static/item5.png"},{name: "车道指示器",src: "/static/item6.png"},{name: "车道指示器",src: "/static/item7.png"},{name: "车道指示器",src: "/static/item8.png"},],circleRadius: 240, // 圆的半径itemSize: 120, // 每个view的大小}},methods: {// 计算每个 view 的样式getItemStyle(index) {const {itemList,circleRadius,itemSize} = this;const angle = (2 * Math.PI) / itemList.length; // 每个 view 的角度间隔const centerX = circleRadius + itemSize / 2; // 圆心的 x 坐标const centerY = circleRadius + itemSize / 2; // 圆心的 y 坐标const radius = circleRadius + itemSize / 2; // view 的圆心距离(圆的半径加上 view 大小的一半)const x = Math.round(centerX + radius * Math.cos(angle * index - Math.PI / 2)); // 计算 x 坐标const y = Math.round(centerY + radius * Math.sin(angle * index - Math.PI / 2)); // 计算 y 坐标return {width: itemSize + "rpx",height: itemSize + "rpx",position: "absolute",top: y + "rpx",left: x + "rpx",transform: `translate(-50%, -50%)`, // 居中显示};},}}
</script><style lang="scss">page {background-color: #619fe1;}.add {// border: 1px solid black;image {width: 60rpx;height: 60rpx;}text-align:right;padding:2% 2% 0 0;}.container_position {width: 100%;display: flex;justify-content: center;align-items: center;.container_info {width: 95%;/* 整体位置 */.position {/* border: 1px solid black; */position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);}/* 圆的样式 */.circle {width: 600rpx;height: 600rpx;border-radius: 50%;/* border: 1px solid black; */}/* 中间图标 */.center-image {width: 160rpx;height: 160rpx;position: absolute;top: 50%;left: 50%;border-radius: 50%;transform: translate(-50%, -50%);box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);}/* 小图标 */.item {display: flex;flex-direction: column;align-items: center;justify-content: center;text-align: center;// border: 1px solid black;view {font-size: 90%;width: 120%;margin-top: 10%;}}/* 小图标的图片信息 */.item img {width: 100rpx;height: 100rpx;border-radius: 50%;box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);}}}
</style>

http://www.lryc.cn/news/179321.html

相关文章:

  • 归一化和标准化的联系与区别及建议
  • 数据结构--栈的实现
  • 第十章 异常
  • Rust冒泡排序
  • 麒麟信安服务器操作系统V3.5.2重磅发布!
  • 密码技术 (1) - 对称密码
  • 基于PYQT5的GUI开发系列教程【二】QT五个布局的介绍与运用
  • Cadence PCB 焊盘和封装
  • 正在等待操作系统重新启动。 请重新启动计算机以安装autocad 2024。
  • Windows电脑显示部分功能被组织控制
  • Django模板加载与响应
  • Python 内置函数详解 (4) 类型转换
  • SpringBoot之Web原生组件注入
  • [每周一更]-(第64期):Dockerfile构造php定制化镜像
  • 若依不分离+Thymeleaf select选中多个回显
  • OCX 添加方法和事件 HTML调用ocx函数及回调 ocx又调用dll VS2017
  • 苹果iPhone手机使用草柴返利APP查询领取淘宝天猫京东优惠券如何取消关闭粘贴商品链接时的弹窗提示?
  • 主机安装elasticsearch后无法登陆
  • 【面试题精讲】JavaSe和JavaEE的区别
  • React 全栈体系(十五)
  • 【逆向】(c++)分析pe结构,拉伸pe结构,缩小pe结构
  • PyTorch实战:常用卷积神经网络搭建结构速览
  • 排序算法之【快速排序】
  • 声明式调用 —— SpringCloud OpenFeign
  • LuatOS-SOC接口文档(air780E)-- fota - 底层固件升级
  • 第二章 Introduction
  • WebGL 渲染三维图形作为纹理贴到另一个三维物体表面
  • 国庆《乡村振兴战略下传统村落文化旅游设计》许少辉八一新书行将售罄
  • Source Insight 工具栏图标功能介绍
  • 模板与泛型编程-函数模板