index.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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-tag :text="text" :type="type" :shape="shape" :closeable="closeable" :mode="mode" @close="close" @click="click" :show="show" :size="size" />
  8. </view>
  9. </view>
  10. <view class="u-config-wrap">
  11. <view class="u-config-title u-border-bottom">参数配置</view>
  12. <view class="u-config-item">
  13. <view class="u-item-title">模式选择</view>
  14. <u-subsection :list="['light', 'dark', 'plain']" @change="modeChange"></u-subsection>
  15. </view>
  16. <view class="u-config-item">
  17. <view class="u-item-title">显示内容</view>
  18. <u-subsection :list="['蒹葭苍苍', '白露为霜', '在水一方']" @change="textChange"></u-subsection>
  19. </view>
  20. <view class="u-config-item">
  21. <view class="u-item-title">主题选择</view>
  22. <u-subsection current="2" :list="['primary', 'success', 'error', 'warning', 'info']" @change="typeChange"></u-subsection>
  23. </view>
  24. <view class="u-config-item">
  25. <view class="u-item-title">形状</view>
  26. <u-subsection :list="['square', 'circle', 'circleLeft', 'circleRight']" @change="shapeChange"></u-subsection>
  27. </view>
  28. <view class="u-config-item">
  29. <view class="u-item-title">尺寸</view>
  30. <u-subsection :list="['default', 'mini']" @change="sizeChange"></u-subsection>
  31. </view>
  32. <view class="u-config-item">
  33. <view class="u-item-title">关闭图标</view>
  34. <u-subsection :list="['是', '否']" @change="closeableChange"></u-subsection>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. text: '蒹葭苍苍',
  44. mode: 'light',
  45. type: 'error',
  46. size: 'default',
  47. shape: 'square',
  48. closeable: true,
  49. show: true
  50. };
  51. },
  52. methods: {
  53. modeChange(index) {
  54. this.mode = index == 0 ? 'light' : index == 1 ? 'dark' : 'plain';
  55. },
  56. textChange(index) {
  57. this.text = index == 0 ? '蒹葭苍苍' : index == 1 ? '白露为霜' : '在水一方';
  58. },
  59. typeChange(index) {
  60. this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning' : 'info';
  61. },
  62. shapeChange(index) {
  63. this.shape = index == 0 ? 'square' : index == 1 ? 'circle' : index == 2 ? 'circleLeft' : 'circleRight';
  64. },
  65. sizeChange(index) {
  66. this.size = index == 0 ? 'default' : 'mini';
  67. },
  68. closeableChange(index) {
  69. this.closeable = index == 0 ? true : false;
  70. },
  71. click(index) {
  72. this.$refs.uToast.show({
  73. title: `第${index + 1}个标签被点击`,
  74. type: 'success'
  75. });
  76. },
  77. close(index) {
  78. this.$refs.uToast.show({
  79. title: `关闭图标被点击`,
  80. type: 'success'
  81. });
  82. }
  83. }
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. .u-demo {
  88. }
  89. </style>