index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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">GRB转HEX</view>
  17. <u-subsection :list="['rgb(12,57,231)', 'rgb(15,148,32)', 'rgb(91,52,210)']" @change="rgbToHexChange"></u-subsection>
  18. </view>
  19. <view class="u-config-item">
  20. <view class="u-item-title">HEX转GRB</view>
  21. <u-subsection :list="['#0edc8a', '#d0a73c', '#3308dd']" @change="hexToRgbChange"></u-subsection>
  22. </view>
  23. <view class="u-config-item">
  24. <view class="u-item-title">颜色渐变(rgb(21,21,21)-rgb(56,56,56),分10份)</view>
  25. <u-button @click="colorGradientChange">执行</u-button>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. result: null
  35. }
  36. },
  37. onLoad() {
  38. this.result = this.$u.rgbToHex('rgb(12,57,231)')
  39. },
  40. methods: {
  41. rgbToHexChange(index) {
  42. let color = index == 0 ? 'rgb(12,57,231)' : index == 1 ? 'rgb(15,148,32)' : 'rgb(91,52,210)';
  43. this.result = this.$u.rgbToHex(color)
  44. },
  45. hexToRgbChange(index) {
  46. let color = index == 0 ? '#0edc8a' : index == 1 ? '#d0a73c' : '#3308dd';
  47. this.result = this.$u.hexToRgb(color)
  48. },
  49. colorGradientChange(index) {
  50. this.result = JSON.stringify(this.$u.colorGradient('rgb(21,21,21)', 'rgb(56,56,56)', 10))
  51. },
  52. getResult() {
  53. this.result = this.$u.guid(this.length, this.firstU, this.radix);
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .u-demo {}
  60. </style>