Merge pull request #265 from SnailSword/master

link支持自定义a标签的target
This commit is contained in:
liaoxuezhi 2019-09-27 15:01:34 +08:00 committed by GitHub
commit 5856515bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -124,6 +124,12 @@ export default {
type: 'tpl',
tpl: '定制内容示例:当前有 ${count} 条数据。',
className: 'v-middle'
}, {
type: 'link',
href: 'https://www.baidu.com',
body: '百度一下',
htmlTarget: '_parent',
className: 'v-middle'
}, {
type: 'columns-toggler',
align: 'right'

View File

@ -16,13 +16,13 @@ export class LinkField extends React.Component<LinkProps, object> {
};
render() {
const {className, body, href, classnames: cx, blank, data, render} = this.props;
const {className, body, href, classnames: cx, blank, htmlTarget, data, render} = this.props;
let value = this.props.value;
const finnalHref = href ? filter(href, data) : '';
return (
<a href={finnalHref || value} target={blank ? '_blank' : '_self'} className={cx('Link', className)}>
<a href={finnalHref || value} target={htmlTarget || (blank ? '_blank' : '_self')} className={cx('Link', className)}>
{body ? render('body', body) : finnalHref || value || '链接'}
</a>
);