123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <template>
- <view :class="['style-box' , `${pageStyle}_style-box` ]" @click.stop="setPagesStyle()">
- <view :class="['style-status' , `${pageStyle}_style` ]">
- <text class="iconfont" v-if="pageStyle === 'daytime'"></text>
- <text class="iconfont" v-else-if="pageStyle === 'black'"></text>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- pageStyle: 'black' , // daytime : '日渐模式' , black: 夜间模式
- };
- },
- methods:{
- setPagesStyle(){
- // this.pageStyle = this.pageStyle === 'daytime' ? 'black' : 'daytime'
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .daytime_style-box{
- background-color: #fcfcfc;
- background-color: #5C5F70;
- }
- .black_style-box{
- background-color: #5C5F70;
- }
- .style-box{
- width: 68rpx;
- height: 40rpx;
- border-radius: 30rpx;
- position: relative;
- .style-status{
- width: 36rpx;
- height: 36rpx;
- background-color: #fff;
- border-radius: 50%;
- position: absolute;
- top: 50%;
- left: 5rpx;
- transform: translateY(-50%);
- // transition: left 3s linear;
- transition:left,background 0.5s;
- display: flex;
- justify-content: center;
- align-items: center;
- .iconfont{
- color: $Theme-Color;
- font-size: 26rpx;
- }
- }
- .black_style{
- left: 30rpx;
- // width:100rpx;
- }
- .daytime_style{
- left: 4rpx;
- }
-
- }
- </style>
|