当前位置:   article > 正文

微信小程序之vue按钮切换内容变化

微信小程序之vue按钮切换内容变化

效果图如下;

上代码

  1. <template>
  2. <view class="content">
  3. <view class="searchDiv">
  4. <view class="paytab">
  5. <view class="buttab" v-for="(t,index) in tabList" :key="index" @click="tabsOn(t.id)" >
  6. <text :class="t.id == tabsId ? 'fontColorBox' : 'default'">{{t.title}}</text>
  7. <hr :class="t.id == tabsId ? 'lineBox' : 'default'"/>
  8. </view>
  9. </view>
  10. <view class="jzalldiv">
  11. <image class="paylog" src="../../static/images/1.png"></image>
  12. <view class="jzall" bindtap="showSelectBox">
  13. 支付宝
  14. </view>
  15. <image class="sanjiao" src="../../static/sanjiao.png"></image>
  16. <input type="text" class="moneyInput" placeholder="¥0.00"/>
  17. </view>
  18. </view>
  19. <!-- 内容布局 -->
  20. <swiper @click="slideOn" :current="tabsId" circular>
  21. <!-- circular 启用循环滑动 -->
  22. <swiper-item>
  23. <view class="paytypelist">
  24. <view class="paytype">
  25. <image src="../../static/images/1.png" class="typeImg"></image>
  26. <view class="typeName">
  27. 蔬菜
  28. </view>
  29. </view>
  30. <view class="paytype">
  31. <image src="../../static/images/1.png" class="typeImg"></image>
  32. <view class="typeName">
  33. 蔬菜
  34. </view>
  35. </view>
  36. <view class="paytype">
  37. <image src="../../static/images/1.png" class="typeImg"></image>
  38. <view class="typeName">
  39. 蔬菜
  40. </view>
  41. </view>
  42. <view class="paytype">
  43. <image src="../../static/images/1.png" class="typeImg"></image>
  44. <view class="typeName">
  45. 蔬菜
  46. </view>
  47. </view>
  48. <view class="paytype">
  49. <image src="../../static/images/1.png" class="typeImg"></image>
  50. <view class="typeName">
  51. 蔬菜
  52. </view>
  53. </view>
  54. <view class="paytype">
  55. <image src="../../static/images/1.png" class="typeImg"></image>
  56. <view class="typeName">
  57. 蔬菜
  58. </view>
  59. </view>
  60. <view class="paytype">
  61. <image src="../../static/images/1.png" class="typeImg"></image>
  62. <view class="typeName">
  63. 蔬菜
  64. </view>
  65. </view>
  66. <view class="paytype">
  67. <image src="../../static/images/1.png" class="typeImg"></image>
  68. <view class="typeName">
  69. 蔬菜
  70. </view>
  71. </view>
  72. <view class="paytype">
  73. <image src="../../static/images/1.png" class="typeImg"></image>
  74. <view class="typeName">
  75. 蔬菜
  76. </view>
  77. </view>
  78. <view class="paytype">
  79. <image src="../../static/images/1.png" class="typeImg"></image>
  80. <view class="typeName">
  81. 自定义
  82. </view>
  83. </view>
  84. </view>
  85. </swiper-item>
  86. <swiper-item>
  87. <view class="paytypelist">
  88. <view class="paytype">
  89. <image src="../../static/images/1.png" class="typeImg"></image>
  90. <view class="typeName">
  91. 蔬菜
  92. </view>
  93. </view>
  94. <view class="paytype">
  95. <image src="../../static/images/1.png" class="typeImg"></image>
  96. <view class="typeName">
  97. 蔬菜
  98. </view>
  99. </view>
  100. <view class="paytype">
  101. <image src="../../static/images/1.png" class="typeImg"></image>
  102. <view class="typeName">
  103. 蔬菜
  104. </view>
  105. </view>
  106. <view class="paytype">
  107. <image src="../../static/images/1.png" class="typeImg"></image>
  108. <view class="typeName">
  109. 蔬菜
  110. </view>
  111. </view>
  112. <view class="paytype">
  113. <image src="../../static/images/1.png" class="typeImg"></image>
  114. <view class="typeName">
  115. 蔬菜
  116. </view>
  117. </view>
  118. <view class="paytype">
  119. <image src="../../static/images/1.png" class="typeImg"></image>
  120. <view class="typeName">
  121. 蔬菜
  122. </view>
  123. </view>
  124. <view class="paytype">
  125. <image src="../../static/images/1.png" class="typeImg"></image>
  126. <view class="typeName">
  127. 蔬菜
  128. </view>
  129. </view>
  130. </view>
  131. </swiper-item>
  132. <swiper-item>
  133. <view class="paytype">
  134. <image src="../../static/images/1.png" class="typeImg"></image>
  135. <view class="typeName">
  136. 蔬菜
  137. </view>
  138. </view>
  139. <view class="paytype">
  140. <image src="../../static/images/1.png" class="typeImg"></image>
  141. <view class="typeName">
  142. 蔬菜
  143. </view>
  144. </view>
  145. <view class="paytype">
  146. <image src="../../static/images/1.png" class="typeImg"></image>
  147. <view class="typeName">
  148. 自定义
  149. </view>
  150. </view>
  151. </swiper-item>
  152. </swiper>
  153. </view>
  154. </template>
  155. <script>
  156. export default {
  157. data() {
  158. return {
  159. "tabList": [// tab选项
  160. {title: "支出",id: "0",},
  161. {title: "收入",id: "1",},
  162. {title: "转账",id: "2",},
  163. ],
  164. "tabsId": 0, //默认选型为装备
  165. }
  166. },
  167. methods: {
  168. // 滑动时触发的事件
  169. slideOn(e) {
  170. this.tabsId=e;
  171. },
  172. //点击tab时触发
  173. tabsOn(e) {
  174. this.tabsId= e;
  175. },
  176. }
  177. }
  178. </script>
  179. <style>
  180. .paytype,.jdheadtitle1,.jdtop,.jdbottom,.jdheaddiv,.jdlist,.jdhead,.jdtitle,.selectTime,
  181. .picsView,.moneyInput,.paylog,.buttab,.paytab,.quxBut,.submitBut,.paybeizhu,.paytypelist,.outmoney,.jzalldiv,.sanjiao,.jzall{
  182. float: left;
  183. }
  184. .default{}
  185. .fontColorBox {
  186. /* 选中tab样式 */
  187. color: black;
  188. font-size: 25px;
  189. font-weight: bold;
  190. }
  191. .lineBox {
  192. /* 线条样式 */
  193. width: 90rpx;
  194. height: 8rpx;
  195. background: black;
  196. margin-top: 7rpx;
  197. border-radius: 4rpx;
  198. }
  199. .addImgBtn {
  200. width:100%;
  201. float: left;
  202. margin-left: 30rpx;
  203. margin-top: 20rpx;
  204. border-top: 1rpx solid rgba(68,68,68,0.1);
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. padding: 12rpx 24rpx;
  209. font-size: 30rpx;
  210. font-family: PingFang SC;
  211. font-weight: bold;
  212. color: #333333;
  213. }
  214. .addImgBtn image {
  215. float: left;
  216. width: 50rpx;
  217. height: 50rpx;
  218. }
  219. .picsView{
  220. margin-left: 30rpx;
  221. }
  222. .addImgBtn text{
  223. font-size: 11px;
  224. color: #2979FF;
  225. font-weight: 100;
  226. }
  227. .moneyInput{
  228. width: 50%;
  229. height: 40px;
  230. text-align: right;
  231. margin-left: 8%;
  232. font-size: 22px;
  233. font-weight: bold;
  234. }
  235. .buttab{
  236. height: 100%;
  237. margin-left: 10%;
  238. font-size: 20px;
  239. /* border-bottom: 2px solid red; */
  240. }
  241. .paytab{
  242. width: 80%;
  243. margin-left: 15%;
  244. height: 30px;
  245. }
  246. .quxBut{
  247. background-color: red;
  248. }
  249. .submitBut{
  250. background-color: #7CFC00;
  251. margin-bottom: 30px;
  252. }
  253. .quxBut,.submitBut{
  254. width: 80%;
  255. height: 25px;
  256. margin-left: 10%;
  257. margin-top: 15px;
  258. border-radius: 5px;
  259. text-align: center;
  260. padding-top: 5px;
  261. color: white;
  262. }
  263. .paybeizhu{
  264. width: 80%;
  265. height: 120px;
  266. padding-left: 5px;
  267. padding-top: 5px;
  268. border-radius: 10px;
  269. margin-left: 10%;
  270. margin-top: 20px;
  271. border: 1px solid #C0C0C0;
  272. }
  273. .paytypelist{
  274. width: 80%;
  275. margin-top: 10px;
  276. margin-left: 10%;
  277. }
  278. .paytype{
  279. width: 13%;
  280. height: 60px;
  281. margin-top: 10px;
  282. margin-left: 6%;
  283. font-size: 12px;
  284. border-radius: 10px;
  285. }
  286. .typeImg{
  287. float: left;
  288. width: 100%;
  289. height: 40px;
  290. border-radius: 50%
  291. }
  292. .typeName{
  293. float: left;
  294. width: 100%;
  295. height: 20px;
  296. padding-top: 5px;
  297. text-align: center;
  298. }
  299. .dbTab{
  300. position: fixed;
  301. z-index: 29;
  302. width:40px;
  303. height:40px;
  304. border-radius: 50%;
  305. display: block;
  306. bottom: 10px;
  307. left: 48%;
  308. }
  309. .jdheadtitle1,.jdheadtitle2{
  310. font-size: 17px;
  311. }
  312. .jdheadtitle1{
  313. width: 70%;
  314. margin-top: 2%;
  315. overflow:hidden;
  316. white-space:nowrap;
  317. text-overflow:ellipsis;
  318. }
  319. .jdheadtitle2{
  320. float: right;
  321. margin-right: 3%;
  322. margin-top: 2%;
  323. }
  324. .jdtop,.jdbottom{
  325. width:100%;
  326. height: 30px;
  327. }
  328. .jdbottom{
  329. padding-top: 5px;
  330. color: #cdcdcd;
  331. font-size: 12px;
  332. }
  333. .jdlist:first-child{
  334. margin-top: 120px;
  335. }
  336. .jdlist{
  337. width: 100%;
  338. height: 60px;
  339. }
  340. .jdheaddiv{
  341. width: 20%;
  342. height: 60px;
  343. }
  344. .jdhead{
  345. width: 50px;
  346. height: 50px;
  347. margin-top: 5px;
  348. margin-left: 15px;
  349. }
  350. .jdtitle{
  351. width:80%;
  352. height: 60px;
  353. border-bottom: 1px solid #e7e6e1;
  354. }
  355. .jzalldiv{
  356. width: 90%;
  357. height: 40px;
  358. margin-top: 20px;
  359. padding-bottom: 5px;
  360. padding-top: 10px;
  361. background-color: #F5F5F5;
  362. margin-left: 5%;
  363. border-radius: 10px;
  364. }
  365. .jzall{
  366. margin-left: 10px;
  367. margin-top: 5px;
  368. font-weight: bold;
  369. font-size: 20px;
  370. }
  371. .paylog{
  372. width: 35px;
  373. height:35px;
  374. margin-left: 10px;
  375. }
  376. .sanjiao{
  377. width: 12px;
  378. height: 12px;
  379. margin-left: 5px;
  380. margin-top: 15px;
  381. }
  382. .headall1{
  383. float: left;
  384. width: 100%;
  385. height: 50%;
  386. }
  387. .searchDiv{
  388. width: 100%;
  389. float: left;
  390. /* background-color:#F5F5F5; */
  391. }
  392. page{
  393. font-family: "Lucida Calligraphy", cursive, serif, sans-serif;
  394. /* background-color: #e7e6e1; e6e6e6*/
  395. }
  396. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/261772
推荐阅读
相关标签
  

闽ICP备14008679号