mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 10:59:42 +08:00
chore: 导出 Excel 的 tpl 模式默认滤掉 html 标签 (#2147)
This commit is contained in:
parent
56e9602869
commit
6d8f264720
@ -155,7 +155,8 @@ export default {
|
||||
{
|
||||
name: 'engine.version',
|
||||
label: 'CSS版本',
|
||||
tpl: '${engine.version}'
|
||||
type: 'tpl',
|
||||
tpl: '<b>${engine.version}</b>'
|
||||
},
|
||||
{
|
||||
name: 'grade',
|
||||
|
@ -15,7 +15,8 @@ import {
|
||||
noop,
|
||||
autobind,
|
||||
isArrayChildrenModified,
|
||||
getVariable
|
||||
getVariable,
|
||||
removeHTMLTag
|
||||
} from '../../utils/helper';
|
||||
import {resolveVariable} from '../../utils/tpl-builtin';
|
||||
import debounce from 'lodash/debounce';
|
||||
@ -1993,9 +1994,8 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
}
|
||||
} else {
|
||||
if ((column as TplSchema).tpl) {
|
||||
sheetRow.getCell(columIndex).value = filter(
|
||||
(column as TplSchema).tpl,
|
||||
row.data
|
||||
sheetRow.getCell(columIndex).value = removeHTMLTag(
|
||||
filter((column as TplSchema).tpl, row.data)
|
||||
);
|
||||
} else {
|
||||
sheetRow.getCell(columIndex).value = value;
|
||||
|
@ -1584,3 +1584,8 @@ export function detectPropValueChanged<
|
||||
onChange(props.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
// 去掉字符串中的 html 标签,不完全准确但效率比较高
|
||||
export function removeHTMLTag(str: string) {
|
||||
return str.replace(/<\/?[^>]+(>|$)/g, '');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user