style.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view :class="['style-box' , `${pageStyle}_style-box` ]" @click.stop="setPagesStyle()">
  3. <view :class="['style-status' , `${pageStyle}_style` ]">
  4. <text class="iconfont" v-if="pageStyle === 'daytime'">&#xe60f;</text>
  5. <text class="iconfont" v-else-if="pageStyle === 'black'">&#xe8b1;</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. pageStyle: 'black' , // daytime : '日渐模式' , black: 夜间模式
  14. };
  15. },
  16. methods:{
  17. setPagesStyle(){
  18. // this.pageStyle = this.pageStyle === 'daytime' ? 'black' : 'daytime'
  19. }
  20. }
  21. }
  22. </script>
  23. <style lang="scss" scoped>
  24. .daytime_style-box{
  25. background-color: #fcfcfc;
  26. background-color: #5C5F70;
  27. }
  28. .black_style-box{
  29. background-color: #5C5F70;
  30. }
  31. .style-box{
  32. width: 68rpx;
  33. height: 40rpx;
  34. border-radius: 30rpx;
  35. position: relative;
  36. .style-status{
  37. width: 36rpx;
  38. height: 36rpx;
  39. background-color: #fff;
  40. border-radius: 50%;
  41. position: absolute;
  42. top: 50%;
  43. left: 5rpx;
  44. transform: translateY(-50%);
  45. // transition: left 3s linear;
  46. transition:left,background 0.5s;
  47. display: flex;
  48. justify-content: center;
  49. align-items: center;
  50. .iconfont{
  51. color: $Theme-Color;
  52. font-size: 26rpx;
  53. }
  54. }
  55. .black_style{
  56. left: 30rpx;
  57. // width:100rpx;
  58. }
  59. .daytime_style{
  60. left: 4rpx;
  61. }
  62. }
  63. </style>