12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import baseComponent from '../helpers/baseComponent'
-
- baseComponent({
- externalClasses: ['wux-class'],
- properties: {
- type: {
- type: String,
- value: '',
- },
- size: {
- type: [String, Number],
- value: 32,
- observer: 'updated',
- },
- color: {
- type: String,
- value: '',
- },
- hidden: {
- type: Boolean,
- value: false,
- },
- },
- data: {
- fontSize: '',
- },
- methods: {
- updated(size = this.data.size) {
- let fontSize = size
-
- if (typeof size === 'number') {
- fontSize = `${size}px`
- } else if (typeof size === 'string') {
- if (!isNaN(Number(size))) {
- fontSize = `${size}px`
- }
- }
-
- if (this.data.fontSize !== fontSize) {
- this.setData({
- fontSize,
- })
- }
- },
- },
- attached() {
- this.updated()
- },
- })
|