Divider.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <ModuleBase :type="data.type">
  3. <template #content>
  4. <div v-if="'wavy' === data.property.line_type" class="wavy" :style="settingWavyStyle"></div>
  5. <hr v-else :style="settingStyle" />
  6. </template>
  7. </ModuleBase>
  8. </template>
  9. <script>
  10. import { getDividerData } from '@/views/book/courseware/data/divider';
  11. import ModuleMixin from '../../common/ModuleMixin';
  12. export default {
  13. name: 'DividerPage',
  14. mixins: [ModuleMixin],
  15. data() {
  16. return {
  17. data: getDividerData(),
  18. };
  19. },
  20. computed: {
  21. settingStyle() {
  22. return {
  23. margin: `${this.data.property.height / 2}px 0`,
  24. border: 'none',
  25. borderTop: `1px ${this.data.property.line_type} ${this.data.property.color}`,
  26. width: `${this.data.property.width}px`,
  27. };
  28. },
  29. settingWavyStyle() {
  30. return {
  31. margin: `${this.data.property.height / 2}px 0`,
  32. width: `${this.data.property.width}px`,
  33. height: '11px',
  34. color: `${this.data.property.color}`,
  35. letterSpacing: `${this.data.property.width}px`,
  36. };
  37. },
  38. },
  39. methods: {},
  40. };
  41. </script>
  42. <style lang="scss" scoped>
  43. .wavy {
  44. display: block;
  45. padding-top: 0.5em;
  46. overflow: hidden;
  47. white-space: nowrap;
  48. }
  49. .wavy::before {
  50. /* IE浏览器实线代替 */
  51. text-decoration: overline;
  52. /* 现代浏览器 */
  53. text-decoration: overline wavy;
  54. content: '\2000';
  55. }
  56. </style>