index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-button @click="openPage">点击跳转</u-button>
  7. </view>
  8. </view>
  9. <view class="u-config-wrap">
  10. <view class="u-config-title u-border-bottom">
  11. 参数配置
  12. </view>
  13. <view class="u-config-item">
  14. <view class="u-item-title">类型</view>
  15. <u-subsection :list="['navigateTo', 'switchTab', 'navigateBack']" @change="typeChange"></u-subsection>
  16. </view>
  17. <view class="u-config-item">
  18. <view class="u-item-title">携带参数(针对type=navigateTo)</view>
  19. <u-subsection :list="['是', '否']" @change="paramsChange"></u-subsection>
  20. </view>
  21. <view class="u-config-item">
  22. <view class="u-item-title">窗口动画(App且type=navigateTo||navigateBack时有效)</view>
  23. <u-subsection :list="['是', '否']" @change="animateChange"></u-subsection>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. type: 'to',
  33. params: {
  34. age: 22,
  35. name: '李商隐'
  36. },
  37. animate: 'slide-in-bottom',
  38. url: ''
  39. }
  40. },
  41. computed: {
  42. jumpUrl() {
  43. let url = '';
  44. if(this.type == 'to') {
  45. url = '/pages/library/route/routeTo';
  46. } else if(this.type == 'tab') {
  47. url = '/pages/example/template';
  48. }
  49. return url;
  50. }
  51. },
  52. methods: {
  53. openPage() {
  54. this.$u.route({
  55. type: this.type,
  56. params: this.params,
  57. url: this.jumpUrl,
  58. animationType: this.animate
  59. });
  60. },
  61. typeChange(index) {
  62. this.type = index == 0 ? 'to' : index == 1 ? 'tab' : 'back';
  63. },
  64. paramsChange(index) {
  65. if(!index) {
  66. this.params = {
  67. age: 22,
  68. name: '李商隐'
  69. }
  70. } else {
  71. this.params = {}
  72. }
  73. },
  74. animateChange(index) {
  75. this.animate = index == 0 ? 'slide-in-bottom' : '';
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .wrap {
  82. padding: 24rpx;
  83. }
  84. </style>