style2.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template id="title-block-style2">
  2. <div class="title-block-style2" flex="cross:center">
  3. <!-- 图片位置 -->
  4. <div class="line-left" :style="{background: computedStyle.titleColor}"></div>
  5. <div class="title" :style="{color: computedStyle.titleColor}">{{title}}</div>
  6. </div>
  7. </template>
  8. <script>
  9. /**
  10. * @descriptions
  11. * 1. 组件名字必须对应模板形式 - 递归组件name
  12. * 2. 样式内容方法尽量内部维护 - 前端方便通用
  13. * 3. 父级组件会传预览数据 - activeItem
  14. */
  15. Vue.component('title-block-style2', {
  16. name: "title-block-style2",
  17. props: {
  18. title: {
  19. type: String,
  20. default () {
  21. return "标题"
  22. }
  23. },
  24. computedStyle: {
  25. type: Object,
  26. default () {
  27. return {}
  28. }
  29. }
  30. },
  31. template: '#title-block-style2',
  32. });
  33. </script>
  34. <style scoped lang="scss">
  35. .title-block-style2 {
  36. position: relative;
  37. height: 33px;
  38. .line-left {
  39. position: absolute;
  40. content: "";
  41. top: 0;
  42. bottom: 0;
  43. left: 10px;
  44. margin: auto;
  45. width: 2px;
  46. height: 14px;
  47. background: #000;
  48. }
  49. .title {
  50. margin: 0 20px;
  51. font-size: 14px;
  52. }
  53. }
  54. </style>