new-nvue-page-2.nvue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view class="root">
  3. <view class="page-body">
  4. <view class="new-page__color" @click="setColorIndex(colorIndex>1?0:colorIndex+1)" :style="{backgroundColor:currentColor}">
  5. <text class="new-page__color-text">点击改变颜色</text>
  6. </view>
  7. <view class="new-page__text-box">
  8. <text class="new-page__text">点击上方色块使用vuex在页面之间进行通讯</text>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import {mapState,mapGetters,mapMutations} from 'vuex'
  15. export default {
  16. data() {
  17. return {
  18. }
  19. },
  20. computed:{
  21. ...mapState(['colorIndex','colorList']),
  22. ...mapGetters(['currentColor'])
  23. },
  24. methods:{
  25. ...mapMutations(['setColorIndex'])
  26. }
  27. }
  28. </script>
  29. <style>
  30. .new-page__text {
  31. font-size: 14px;
  32. color: #666666;
  33. }
  34. .root{
  35. flex-direction: column;
  36. }
  37. .page-body{
  38. flex: 1;
  39. flex-direction: column;
  40. justify-content: flex-start;
  41. align-items: center;
  42. padding-top: 50px;
  43. }
  44. .new-page__text-box{
  45. padding: 20px;
  46. }
  47. .new-page__color{
  48. width: 200px;
  49. height: 100px;
  50. justify-content: center;
  51. align-items: center;
  52. }
  53. .new-page__color-text{
  54. font-size: 14px;
  55. color: #FFFFFF;
  56. line-height: 30px;
  57. text-align: center;
  58. }
  59. .new-page__button-item{
  60. margin-top: 15px;
  61. width: 300px;
  62. }
  63. </style>