font-size-select.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <el-select class="fontSizeSelect" v-model="fontVal" placeholder="请选择" @change="fontChange">
  3. <el-option
  4. v-for="item in fontList"
  5. :key="item.value"
  6. :label="item.label"
  7. :value="item.value">
  8. <span :style="{fontSize:item.value+'px'}">{{ item.label }}</span>
  9. </el-option>
  10. </el-select>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'font-size-select',
  15. props: {
  16. fontSize: {
  17. type: String,
  18. default: '12'
  19. }
  20. },
  21. data () {
  22. return {
  23. fontVal: '',
  24. fontList: [{
  25. value: '12',
  26. label: '12px'
  27. }, {
  28. value: '14',
  29. label: '14px'
  30. }, {
  31. value: '16',
  32. label: '16px'
  33. }, {
  34. value: '18',
  35. label: '18px'
  36. }, {
  37. value: '20',
  38. label: '20px'
  39. }, {
  40. value: '22',
  41. label: '22px'
  42. }, {
  43. value: '24',
  44. label: '24px'
  45. }, {
  46. value: '28',
  47. label: '28px'
  48. }, {
  49. value: '32',
  50. label: '32px'
  51. }, {
  52. value: '36',
  53. label: '36px'
  54. }]
  55. }
  56. },
  57. mounted () {
  58. this.fontVal = this.fontSize
  59. },
  60. methods: {
  61. // 获取类别
  62. fontChange (val) {
  63. this.$emit('update:fontSize', val)
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .fontSizeSelect{
  70. width: 100px;
  71. }
  72. </style>