index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 ref="uToast"></u-toast>
  7. <u-alert-tips @close="close" :closeAble="closeAble" :show="show" @click="click"
  8. :type="type" :title="title" :description="description" :showIcon="showIcon"></u-alert-tips>
  9. </view>
  10. </view>
  11. <view class="u-config-wrap">
  12. <view class="u-config-title u-border-bottom">
  13. 参数配置
  14. </view>
  15. <view class="u-config-item">
  16. <view class="u-item-title">左侧图标</view>
  17. <u-subsection current="1" :list="['是', '否']" @change="showIconChange"></u-subsection>
  18. </view>
  19. <view class="u-config-item">
  20. <view class="u-item-title">关闭图标</view>
  21. <u-subsection current="1" :list="['显示', '隐藏']" @change="closeAbleChange"></u-subsection>
  22. </view>
  23. <view class="u-config-item">
  24. <view class="u-item-title">主题</view>
  25. <u-subsection current="3" :list="['primary', 'success', 'error', 'warning', 'info']" @change="typeChange"></u-subsection>
  26. </view>
  27. <view class="u-config-item">
  28. <view class="u-item-title">状态</view>
  29. <u-subsection :current="current" :list="['开启', '关闭']" @change="showChange"></u-subsection>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. title: '大漠孤烟直,长河落日圆',
  39. description: "月落乌啼霜满天,江枫渔火对愁眠。姑苏城外寒山寺,夜半钟声到客船。飞流直下三千尺,疑是银河落九天!",
  40. show: true,
  41. closeAble: false,
  42. showIcon: false,
  43. type: 'warning',
  44. }
  45. },
  46. computed: {
  47. current() {
  48. return this.show ? 0 : 1;
  49. }
  50. },
  51. methods: {
  52. showIconChange(index) {
  53. this.showIcon = index == 0 ? true : false;
  54. },
  55. showChange(index) {
  56. this.show = index == 0 ? true : false;
  57. },
  58. closeAbleChange(index) {
  59. this.closeAble = index == 0 ? true : false;
  60. },
  61. typeChange(index) {
  62. this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning' : 'info';
  63. },
  64. close() {
  65. this.show = false;
  66. this.$refs.uToast.show({
  67. type: 'warning',
  68. title: '点击关闭按钮'
  69. })
  70. },
  71. click() {
  72. this.$refs.uToast.show({
  73. type: 'warning',
  74. title: '点击内容'
  75. })
  76. },
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .wrap {
  82. padding: 24rpx;
  83. }
  84. .item {
  85. margin: 30rpx 0;
  86. }
  87. </style>