Skip to content

Commit c87e803

Browse files
committed
fix: getPropertyValue return null
1 parent a094aed commit c87e803

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ Markdown 文档自动即时渲染为微信图文,让你不再为微信文章
7878
示例代码:
7979

8080
```js
81-
const { file, util, okCb, errCb } = CUSTOM_ARG;
82-
const param = new FormData();
83-
param.append(`file`, file);
81+
const { file, util, okCb, errCb } = CUSTOM_ARG
82+
const param = new FormData()
83+
param.append(`file`, file)
8484
util.axios
8585
.post(`http://127.0.0.1:9000/upload`, param, {
86-
headers: { "Content-Type": `multipart/form-data` },
86+
headers: { 'Content-Type': `multipart/form-data` },
8787
})
8888
.then((res) => {
89-
okCb(res.url);
89+
okCb(res.url)
9090
})
9191
.catch((err) => {
92-
errCb(err);
93-
});
92+
errCb(err)
93+
})
9494

9595
// 提供的可用参数:
9696
// CUSTOM_ARG = {

src/utils/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,21 @@ export function exportHTML(primaryColor: string) {
211211
* @param {排除的属性} excludes 如果某些属性对结果有不良影响,可以使用这个参数来排除
212212
* @returns 行内样式拼接结果
213213
*/
214-
function getElementStyles(element: Element, excludes = [`width`, `height`]) {
214+
function getElementStyles(element: Element, excludes = [`width`, `height`, `inlineSize`, `webkitLogicalWidth`, `webkitLogicalHeight`]) {
215215
const styles = getComputedStyle(element, null)
216216
return Object.entries(styles)
217217
.filter(
218-
([key]) => styles.getPropertyValue(key) && !excludes.includes(key),
218+
([key]) => {
219+
// 将驼峰转换为短横线格式
220+
const kebabKey = key.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)
221+
return styles.getPropertyValue(kebabKey) && !excludes.includes(key)
222+
},
219223
)
220-
.map(([key, value]) => `${key}:${value};`)
224+
.map(([key, value]) => {
225+
// 将驼峰转换为短横线格式
226+
const kebabKey = key.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)
227+
return `${kebabKey}:${value};`
228+
})
221229
.join(``)
222230
}
223231

0 commit comments

Comments
 (0)