const iconMap = require('../../utils/icon-map'); Component({ properties: { // Lucide 图标名,如 search / dumbbell / heart name: { type: String, value: '' }, // 字号(rpx) size: { type: Number, value: 20 }, // 颜色,默认跟随当前文字色(currentColor 在 iconfont 下用具体色) color: { type: String, value: '' }, }, data: { glyph: '' }, observers: { name(n) { this.setData({ glyph: (iconMap[n] || '') }); }, }, lifetimes: { attached() { this.setData({ glyph: (iconMap[this.data.name] || '') }); }, }, });