mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-01 03:28:20 +08:00
iframe支持reload
This commit is contained in:
parent
398320c583
commit
b7dbc4e87f
@ -146,7 +146,9 @@ export default class SubFormControl extends React.PureComponent<SubFormProps, Su
|
||||
disabled,
|
||||
labelField,
|
||||
value,
|
||||
btnLabel
|
||||
btnLabel,
|
||||
render,
|
||||
data
|
||||
} = this.props;
|
||||
|
||||
return [
|
||||
@ -177,8 +179,15 @@ export default class SubFormControl extends React.PureComponent<SubFormProps, Su
|
||||
data-tooltip="编辑详情"
|
||||
data-position="bottom"
|
||||
>
|
||||
{(value && labelField && value[labelField] && stripTag(value[labelField])) ||
|
||||
btnLabel}
|
||||
{(value && labelField && value[labelField] && stripTag(value[labelField]))
|
||||
|| render('placeholder',
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: btnLabel
|
||||
},
|
||||
{
|
||||
data
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
@ -199,7 +208,7 @@ export default class SubFormControl extends React.PureComponent<SubFormProps, Su
|
||||
}
|
||||
|
||||
renderSingle() {
|
||||
const {classPrefix: ns, btnClassName, disabled, value, labelField, btnLabel} = this.props;
|
||||
const {classPrefix: ns, btnClassName, disabled, value, labelField, btnLabel, render, data} = this.props;
|
||||
|
||||
return (
|
||||
<div className={`${ns}SubForm-values`} key="values">
|
||||
@ -216,7 +225,16 @@ export default class SubFormControl extends React.PureComponent<SubFormProps, Su
|
||||
data-position="bottom"
|
||||
>
|
||||
<span className={`${ns}SubForm-valueLabel`}>
|
||||
{(value && labelField && value[labelField] && stripTag(value[labelField])) || btnLabel}
|
||||
{(value && labelField && value[labelField] && stripTag(value[labelField]))
|
||||
|| render('placeholder',
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: btnLabel
|
||||
},
|
||||
{
|
||||
data
|
||||
}
|
||||
)}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import {filter} from '../utils/tpl';
|
||||
import {autobind} from '../utils/helper';
|
||||
import {ScopedContext, IScopedContext} from '../Scoped';
|
||||
|
||||
export interface IFrameProps extends RendererProps {
|
||||
className?: string;
|
||||
@ -8,6 +10,7 @@ export interface IFrameProps extends RendererProps {
|
||||
}
|
||||
|
||||
export default class IFrame extends React.Component<IFrameProps, object> {
|
||||
IFrameRef: React.RefObject<HTMLIFrameElement> = React.createRef();
|
||||
static propsList: Array<string> = ['src', 'className'];
|
||||
static defaultProps: Partial<IFrameProps> = {
|
||||
className: '',
|
||||
@ -16,6 +19,11 @@ export default class IFrame extends React.Component<IFrameProps, object> {
|
||||
frameBorder: 0
|
||||
};
|
||||
|
||||
@autobind
|
||||
reload() {
|
||||
(this.IFrameRef.current as HTMLIFrameElement).src = (this.IFrameRef.current as HTMLIFrameElement).src;
|
||||
}
|
||||
|
||||
render() {
|
||||
let {className, src, width, height, frameBorder, data, style} = this.props;
|
||||
|
||||
@ -31,6 +39,7 @@ export default class IFrame extends React.Component<IFrameProps, object> {
|
||||
className={className}
|
||||
frameBorder={frameBorder}
|
||||
style={style}
|
||||
ref={this.IFrameRef}
|
||||
src={src ? filter(src, data) : undefined}
|
||||
/>
|
||||
);
|
||||
@ -41,4 +50,16 @@ export default class IFrame extends React.Component<IFrameProps, object> {
|
||||
test: /(^|\/)iframe$/,
|
||||
name: 'iframe'
|
||||
})
|
||||
export class IFrameRenderer extends IFrame {}
|
||||
export class IFrameRenderer extends IFrame {
|
||||
static contextType = ScopedContext;
|
||||
|
||||
componentWillMount() {
|
||||
const scoped = this.context as IScopedContext;
|
||||
scoped.registerComponent(this);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
const scoped = this.context as IScopedContext;
|
||||
scoped.unRegisterComponent(this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user