index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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-top-tips ref="uTips"></u-top-tips>
  7. <text class="u-no-demo-here">点击参数配置查看效果</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 :list="['primary', 'success', 'error', 'warning', 'info']" @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="durationChange"></u-subsection>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. duration: 2000,
  30. title: '忽如一夜春风来,千树万树梨花开',
  31. type: 'primary'
  32. }
  33. },
  34. methods: {
  35. showTips() {
  36. this.$refs.uTips.show({
  37. duration: this.duration,
  38. title: this.title,
  39. type: this.type
  40. });
  41. },
  42. typeChange(index) {
  43. this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning' : 'info';
  44. this.showTips();
  45. },
  46. durationChange(index) {
  47. this.duration = index == 0 ? 4000 : index == 1 ? 2000 : 500;
  48. this.showTips();
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .u-demo {}
  55. </style>