new-nvue-page-1.nvue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 class="new-page__button">
  11. <button class="new-page__button-item" @click="navToNvue">跳转NVUE页面</button>
  12. <button class="new-page__button-item" @click="navToVue">跳转VUE页面</button>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {mapState,mapGetters,mapMutations} from 'vuex'
  19. export default {
  20. data() {
  21. return {
  22. }
  23. },
  24. computed:{
  25. ...mapState(['colorIndex','colorList']),
  26. ...mapGetters(['currentColor'])
  27. },
  28. methods:{
  29. ...mapMutations(['setColorIndex']),
  30. navToNvue(){
  31. uni.navigateTo({
  32. url:'new-nvue-page-2'
  33. })
  34. },
  35. navToVue(){
  36. uni.navigateTo({
  37. url:'new-vue-page-2'
  38. })
  39. }
  40. }
  41. }
  42. </script>
  43. <style>
  44. .new-page__text {
  45. font-size: 14px;
  46. color: #666666;
  47. }
  48. .root{
  49. flex-direction: column;
  50. }
  51. .page-body{
  52. flex: 1;
  53. flex-direction: column;
  54. justify-content: flex-start;
  55. align-items: center;
  56. padding-top: 50px;
  57. }
  58. .new-page__text-box{
  59. padding: 20px;
  60. }
  61. .new-page__color{
  62. width: 200px;
  63. height: 100px;
  64. justify-content: center;
  65. align-items: center;
  66. }
  67. .new-page__color-text{
  68. font-size: 14px;
  69. color: #FFFFFF;
  70. line-height: 30px;
  71. text-align: center;
  72. }
  73. .new-page__button-item{
  74. margin-top: 15px;
  75. width: 300px;
  76. }
  77. </style>