Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the switch button of mobile terminal by vue

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to realize the switch button of the mobile terminal by vue". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to realize the switch button of the mobile terminal by vue".

Logic:

1. Write an oval div

two。 Dynamically change the background color of the oval div

3. Write a dot, which is positioned on the oval div by absolute positioning.

4. When switching back and forth, use translateX to move the position of the dot and dynamically change the background color of the oval div

Code:

Html:

Departmental function {{isShow?' Turn on': 'close'}}

Css:

.department {height: px2rem; background: # ffffff; padding: 0 px2rem (66) 0; margin-top: px2rem (4); display: flex; justify-content: space-between;. Department-l {line-height: px2rem (178); font-size: px2rem (53); ccolor: # 303030;}. Department-r {line-height: px2rem (178); font-size: px2rem (50) Color: # 454545;}} .switch {display: inline-block; width: px2rem; height: px2rem; background: # DBDBDB; border-radius: px2rem; position: relative; vertical-align: middle; margin-left: px2rem (31); .switch-circle {position: absolute; left: px2rem (6); top: px2rem (6); width: px2rem (73) Height: px2rem (73); border-radius: 50%; background: # fff;}} .on {background:-webkit-linear-gradient (left, # 19A89F, # 9CDD97); / * Safari 5.16.0* / background:-o-linear-gradient (right, # 19A89F, # 9CDD97) / * Opera 11.112.0 * / background:-moz-linear-gradient (right, # 19A89F, # 9CDD97); / * Firefox 3.615 * / background: linear-gradient (to right, # 19A89F, # 9CDD97); / * Standard syntax (must be placed last) * /} .right {transform: translateX (px2rem (55))}

Js:

Export default {name: "clientCreate", data () {return {isShow:false}}, created: function () {}, mounted: function () {} Methods: {switchDepartment:function () {this.isShowroomroomthis.isShow },}} at this point, I believe you have a deeper understanding of "how to realize the switch button on the mobile side of vue". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report