应无所住,而生其心
排名
1
文章
872
粉丝
112
评论
163
net core webapi post传递参数
庸人 : 确实坑哈,我也是下班好了好几次,发现后台传递对象是可以的,但...
百度编辑器自定义模板
庸人 : 我建议换个编辑器,因为现在百度富文本已经停止维护了,用tinymec...
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术

vue3实现箭头图片展开,收缩效果,打开关闭效果。图片旋转。uni-app,微信小程序,展开关闭 ,模板。

1454人阅读 2022/11/6 16:59 总访问:5415000 评论:0 收藏:0 手机
分类: 前端

如图,主要是说一下右边那个箭头的展开,收缩的效果

其实非常的简单,当打开的时候那个图片旋转个180°即可,所以单独搞一个打开状态的样式:

  1. // 图片的常态样式
  2. .icon-arrow {
  3. width: 20rpx;
  4. height: 12rpx;
  5. }
  6. // 展开的效果图标旋转180°
  7. .icon-arrow-open{
  8. rotate:180deg
  9. }

然后绑定图片的时候,给一个是否增加icon-arrow-open样式的验证就行了,代码如下

  1. <image :src="`${CssImgPath}/imgs/arrow_mini.png`" :class="{'icon-arrow-open':item.isOpen}" class="icon-arrow" />

核心代码就是:

  1. :class="{'icon-arrow-open':item.isOpen}"

这里就是根据循环项里边的isOpen来确定图片是否存在 icon-arrow-open样式,如果存在就是让图片旋转180°,就变成展开状态的效果了。

贴一下这个页面完整的代码

全部都是静态页,是用vscode开发的uni-app,编译到微信小程序运行的,像数单位使用的是rpx

  1. <template>
  2. <div class="schoolSort-container">
  3. <view class="titleWrap">
  4. <view class="title">{{ state.title }}</view>
  5. </view>
  6. <view class="splitline"></view>
  7. <view class="schoolSortContent">
  8. <view v-for="(item, index) in state.schoolData" :key="index">
  9. <view class="schoolSortWrap" @tap="openContent(item)">
  10. <view class="schoolSortItem">
  11. <view class="ssi-sort-name">
  12. <view v-if="index <= 2">
  13. <image class="sort_img" :src="`${CssImgPath}/imgs/sort_${index + 1}.png`" />
  14. </view>
  15. <view class="ssi-sort" v-else>{{ index + 1 }}</view>
  16. <view class="ssi-name">陕西商洛职业技术学院</view>
  17. </view>
  18. <view class="ssi-complete-info-arrow">
  19. <view class="ssi-complete-info">目标达成:{{ (100 - index) }}%</view>
  20. <image :src="`${CssImgPath}/imgs/arrow_mini.png`" :class="{'icon-arrow-open':item.isOpen}" class="icon-arrow" />
  21. </view>
  22. </view>
  23. <view v-show="item.isOpen" class="ssc-situation">
  24. <view class="ssc-si-warp">
  25. <view class="sss-ps-item">
  26. <div class="sss-ps-item-wrap">
  27. <view class="sss-psi-count">19</view>
  28. <view class="sss-psi-desc">目标</view>
  29. </div>
  30. </view>
  31. <view class="sss-ps-item">
  32. <div class="sss-ps-item-wrap">
  33. <view class="sss-psi-count">{{ index }}</view>
  34. <view class="sss-psi-desc">实际完成率</view>
  35. </div>
  36. </view>
  37. <view class="sss-ps-item">
  38. <div class="sss-ps-item-wrap">
  39. <view class="sss-psi-count">3</view>
  40. <view class="sss-psi-desc">目标达成率</view>
  41. </div>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </div>
  49. </template>
  50. <script setup lang="ts" name="tasks">
  51. import { CssImgPath } from '@/common/sysconfig';
  52. import { defineAsyncComponent, reactive, onMounted, toRefs, ref } from 'vue';
  53. const state = reactive({
  54. title: 'TNBLOG-2024上系统使用排名',
  55. schoolData: []
  56. })
  57. onMounted(() => {
  58. // 模拟一点数据
  59. for (let index = 0; index < 10; index++) {
  60. if (index === 0) {
  61. state.schoolData.push({ sort: index, isOpen: true })
  62. }
  63. else {
  64. state.schoolData.push({ sort: index, isOpen: false })
  65. }
  66. }
  67. })
  68. const openContent = (item: any) => {
  69. console.log("点击了")
  70. item.isOpen = !item.isOpen
  71. }
  72. </script>
  73. <style scoped="scoped" lang="scss">
  74. .schoolSort-container {
  75. padding: 30rpx;
  76. // 图片的常态样式
  77. .icon-arrow {
  78. width: 20rpx;
  79. height: 12rpx;
  80. }
  81. // 展开的效果图标旋转180°
  82. .icon-arrow-open{
  83. rotate:180deg
  84. }
  85. .titleWrap {
  86. display: flex;
  87. .title {
  88. font-family: PingFang SC, PingFang SC;
  89. font-weight: 500;
  90. font-size: 36rpx;
  91. color: #313960;
  92. }
  93. }
  94. .splitline {
  95. margin-left: -20rpx;
  96. margin-right: -20rpx;
  97. margin-top: 30rpx;
  98. height: 1rpx;
  99. background: #f3f3f3;
  100. }
  101. .schoolSortWrap {
  102. // margin-top: 20rpx;
  103. min-height: 90rpx;
  104. // margin-bottom: 20rpx;
  105. align-items: center;
  106. border-bottom: 2rpx solid #CBD2DA;
  107. border-bottom-color: rgba(203, 210, 218, 0.2);
  108. //border-bottom-color: rgba(16, 13, 112, 0.7);
  109. .ssc-situation {
  110. background: RGBA(248, 249, 250, 1);
  111. padding: 20rpx;
  112. .ssc-si-warp {
  113. margin-top: 5rpx;
  114. display: flex;
  115. // 让中间间距保持一致
  116. .sss-ps-item+.sss-ps-item {
  117. margin-left: 12rpx;
  118. }
  119. .sss-ps-item {
  120. flex: 1;
  121. height: 102rpx;
  122. background: rgba(179, 179, 179, 0.1);
  123. border-radius: 8rpx 8rpx 8rpx 8rpx;
  124. text-align: center;
  125. display: flex;
  126. justify-content: center;
  127. .sss-ps-item-wrap {
  128. align-self: center;
  129. .sss-psi-count {
  130. font-family: PingFang SC, PingFang SC;
  131. font-weight: 400;
  132. font-size: 24rpx;
  133. color: #5EC6A7;
  134. }
  135. .sss-psi-desc {
  136. font-family: PingFang SC, PingFang SC;
  137. font-weight: 400;
  138. font-size: 24rpx;
  139. color: #B3B3B3;
  140. margin-top: 5rpx;
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. .schoolSortItem {
  148. min-height: 90rpx;
  149. // background-color: #ffabcd;
  150. // border-bottom: 2rpx solid #CBD2DA;
  151. // border-bottom-color: rgba(203, 210, 218, 0.2);
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. .ssi-sort-name {
  156. display: flex;
  157. align-items: center;
  158. .sort_img {
  159. width: 43rpx;
  160. height: 52.13rpx;
  161. padding-top: 10rpx;
  162. // width: 36rpx;
  163. // height: 47.14rpx;
  164. }
  165. .ssi-sort {
  166. text-align: center;
  167. width: 43rpx;
  168. }
  169. .ssi-name {
  170. margin-left: 50rpx;
  171. font-family: PingFang SC, PingFang SC;
  172. font-weight: 400;
  173. font-size: 28rpx;
  174. color: #313960;
  175. }
  176. }
  177. .ssi-complete-info-arrow {
  178. display: flex;
  179. align-items: center;
  180. .ssi-complete-info {
  181. width: 210rpx;
  182. height: 37rpx;
  183. background: rgba(94, 205, 182, 0.1);
  184. border-radius: 8rpx 8rpx 8rpx 8rpx;
  185. text-align: center;
  186. font-family: PingFang SC, PingFang SC;
  187. font-weight: 400;
  188. font-size: 24rpx;
  189. color: #5EC6A7;
  190. margin-right: 15rpx;
  191. }
  192. }
  193. }
  194. }
  195. </style>

欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)

评价

vue3vue组件props给一个对象参数vue组件间传参数vue父组件给子组件传参数组件参数类型父组件调用子组件的方法vue组件事件监听给子组件传递方法子组件调用父组件方法

[TOC]组件可以使用props给组件传值,可以同时传递多个,可以是任意类型,比如字符串或者对象。 下面是个简单的例子: &lt...

vue3最基础的数据加载表格table

vue3表格加载一点静态数据 &lt;template&gt; &lt;el-table :data=&quot;tableData&quot; style=&quot;width: 100%&quot...

vue3 Element Plus 表单输入框放到一行

当垂直方向空间受限且表单较简单时,可以在一行内放置表单。 通过设置 inline 属性为 true 可以让表单域变为行内的表单域...

vue3 Element ui Plus 表格 分页vue3 el-pagination分页

其实就是el-pagination控件的使用而已 &lt;template&gt; &lt;div&gt; &lt;el-table :data=&quot;tableData&quot; ...

vue触发a标签的点击事件vue3 dom操作 触发点击事件 文件选择库只会触发一次change事件的问题

[TOC]vue触发a标签的点击事件直接操作dom节点的方式比较简单 &lt;button @click=&quot;handleBtnClick&quot;&gt;点击按钮&...

vue3 ref的使用多个ref的使用通过ref触发点击事件

多个ref获取的方法可以使用一样的,通过变量名来区分就行了 const vabUploadRef = ref() const multipleTableRef = ref() ...

vue elementuivue3 element plus 文件上传的时候设置其他参数后台.net接收传递的额外参数图片上传

比如上传文件的时候额外传递两个select选择的值 前台前面上传文件的时候要提供默认参数很简单,el-upload绑定一个data即可...

vuevue3 打开新页面页面跳转vue跳转到一个新页面vue路由传参vue3路由传参vue3 获取路由参数

[TOC]VUE页面跳转本地页面跳转 goApplicationCenter() { //进行页面跳转 let path = &quot;/application-center&quo...

vuevue3组件封装vue组件模板简单组件模板基础组件模板vue引入自定义的组件vue使用自定义的组件插槽slot使用vue封装格子效果一块一块的grid布局效果

[TOC]vue封装组件的简单模板贴一个简单模板方便自定义组件的时候直接复制 &lt;template&gt; &lt;div class=&quot;app...

.net6 Signalr+vue3 的运用(上)

.net6 Signalr+Vue3 的运用(上)[TOC] 什么是 SignalR?ASP.NET Core SignalR 是一个开放源代码库,可用于简化向应用添加...

.net6 Signalr+vue3 的运用(下)

.net6 Signalr+Vue3 的运用(下)[TOC] 上篇链接:https://www.tnblog.net/hb/article/details/7961SignalR 中的用户 Sig...

.net6 Signalr+vue3 配合Ingress Nginx的运用

.net6 Signalr+Vue3 配合Ingress Nginx的运用[TOC] 结合上篇:https://www.tnblog.net/hb/article/details/7963 项目打...

vue3 Element Plus 表格使用vue3常用界面搭配vue3基础模板使用

一个简单的表格加时间搜索界面效果如下: 代码如下: &lt;template&gt; &lt;div class=&quot;app-container&quot;&g...

vue3 如何加prototypevue3使用globalProperties

在2.X版本中创建一个vue 实例是通过 new Vue()来实现的,到了3.X中则是通过使用createApp这个 API返回一个应用实例,并且可...