index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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-toast :type="type" ref="uToast"></u-toast>
  7. <text class="no-mode-here">见弹出toast</text>
  8. </view>
  9. </view>
  10. <view class="u-config-wrap">
  11. <view class="u-config-title u-border-bottom">
  12. 参数配置
  13. </view>
  14. <view class="u-config-item">
  15. <view class="u-item-title">主题</view>
  16. <u-subsection :current="4" :list="['primary', 'success', 'error', 'warning', 'default']" @change="typeChange"></u-subsection>
  17. </view>
  18. <view class="u-config-item">
  19. <view class="u-item-title">结束后自动跳转</view>
  20. <u-subsection current="1" :list="['是', '否']" @change="urlChange"></u-subsection>
  21. </view>
  22. <view class="u-config-item">
  23. <view class="u-item-title">位置</view>
  24. <u-subsection current="1" :list="['顶部', '中部', '底部']" @change="positionChange"></u-subsection>
  25. </view>
  26. <view class="u-config-item">
  27. <view class="u-item-title">显示图标</view>
  28. <u-subsection :list="['是', '否']" @change="iconChange"></u-subsection>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. type: 'success',
  38. title: '桃花潭水深千尺',
  39. icon: true,
  40. position: 'center',
  41. url: '',
  42. }
  43. },
  44. methods: {
  45. typeChange(index) {
  46. this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning' : 'default';
  47. this.show();
  48. },
  49. positionChange(index) {
  50. this.position = index == 0 ? 'top' : index == 1 ? 'center' : 'bottom';
  51. this.show();
  52. },
  53. iconChange(index) {
  54. this.icon = index == 0 ? true : false;
  55. this.show();
  56. },
  57. urlChange(index) {
  58. this.url = index == 0 ? '/pages/components/button/index' : '';
  59. this.show();
  60. },
  61. show() {
  62. this.$refs.uToast.show({
  63. title: this.title,
  64. position: this.position,
  65. type: this.type,
  66. icon: this.icon,
  67. url: this.url,
  68. });
  69. },
  70. hide() {
  71. this.$refs.uToast.hide();
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .no-mode-here {
  78. color: $u-tips-color;
  79. font-size: 28rpx;
  80. }
  81. </style>