index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. <view class="u-demo-result-line">
  7. {{result}}
  8. </view>
  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 :list="['min=0, max=5', 'min=541, max=8164']" @change="paramsChange"></u-subsection>
  18. <view class="u-btn-wrap">
  19. <u-button @click="getResult">执行</u-button>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. min: 0,
  30. max: 5,
  31. result: ''
  32. }
  33. },
  34. onLoad() {
  35. this.getResult();
  36. },
  37. methods: {
  38. paramsChange(index) {
  39. if(index == 0) {
  40. this.min = 0;
  41. this.max = 5;
  42. } else {
  43. this.min = 541;
  44. this.max = 8164;
  45. }
  46. this.getResult();
  47. },
  48. getResult() {
  49. this.result = this.$u.random(this.min, this.max);
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .u-btn-wrap {
  56. margin-top: 50rpx;
  57. }
  58. </style>