diff --git a/packages/core/src/elements/config.ts b/packages/core/src/elements/config.ts index 6c304b2f..24b14953 100644 --- a/packages/core/src/elements/config.ts +++ b/packages/core/src/elements/config.ts @@ -1,5 +1,5 @@ import { $creator } from '../utils/creator'; -import { el } from '../utils/dom'; +import { CustomElementStyleAttrs, el } from '../utils/dom'; import { $store } from '../utils/store'; import { ConfigTagMap } from './configs/interface'; @@ -21,7 +21,7 @@ export class ConfigElement extends IElem /** 将本地修改后的值同步到元素中 */ sync?: boolean; /** 元素属性 */ - attrs?: Partial; + attrs?: CustomElementStyleAttrs>; /** tag 为 select 时的选项 */ options?: string[][] | { label: string; value: string; title?: string }[]; _onload?: (this: ConfigTagMap[T], el: this) => void; @@ -117,6 +117,10 @@ export class ConfigElement extends IElem // 合并元素属性 for (const key in this.attrs) { + if (key === 'style') { + Object.assign(this.provider.style, this.attrs[key]); + continue; + } if (Object.prototype.hasOwnProperty.call(this.attrs, key)) { Reflect.set(this.provider, key, Reflect.get(this.attrs, key)); } diff --git a/packages/scripts/src/projects/common.ts b/packages/scripts/src/projects/common.ts index fe1002bb..f6e6c355 100644 --- a/packages/scripts/src/projects/common.ts +++ b/packages/scripts/src/projects/common.ts @@ -290,7 +290,7 @@ export const CommonProject = Project.create({ defaultValue: ['不会', '不知道', '不清楚', '不懂', '不会写'].join('\n'), label: '(仅超星)随机填空文案', tag: 'textarea', - attrs: { title: '每行一个,随机填入' } + attrs: { title: '每行一个,随机填入', style: { minWidth: '200px', minHeight: '50px' } } }, redundanceWordsText: { defaultValue: [ @@ -306,7 +306,10 @@ export const CommonProject = Project.create({ ].join('\n'), label: '题目冗余字段自动删除', tag: 'textarea', - attrs: { title: '在搜题的时候自动删除多余的文字,以便提高搜题的准确度,每行一个。' } + attrs: { + title: '在搜题的时候自动删除多余的文字,以便提高搜题的准确度,每行一个。', + style: { minWidth: '200px', minHeight: '50px' } + } } }, methods() {