forked from p96170835/amis
代码小调整
This commit is contained in:
parent
2e489f25c7
commit
ed28740f27
|
@ -34,6 +34,35 @@ export interface CarouselState {
|
|||
nextAnimation: string;
|
||||
}
|
||||
|
||||
const defaultSchema = {
|
||||
type: 'tpl',
|
||||
tpl: `
|
||||
<% if (data.hasOwnProperty('image')) { %>
|
||||
<div style="background-image: url(<%= data.image %>)" class="image <%= data.imageClassName %>"></div>
|
||||
<% if (data.title) { %>
|
||||
<div class="title <%= data.titleClassName %>"><%= data.title %></div>
|
||||
<% } if (data.description) { %>
|
||||
<div class="description <%= data.descriptionClassName %>"><%= data.description %></div>
|
||||
<% } %>
|
||||
<% } else if (data.hasOwnProperty('html')) { %>
|
||||
<%= data.html %>"
|
||||
<% } else if (data.image) { %>
|
||||
<div style="background-image: url(<%= data.image %>)" class="image <%= data.imageClassName %>"></div>
|
||||
<% if (data.title) { %>
|
||||
<div class="title <%= data.titleClassName %>"><%= data.title %></div>
|
||||
<% } if (data.description) { %>
|
||||
<div class="description <%= data.descriptionClassName %>"><%= data.description %></div>
|
||||
<% } %>
|
||||
<% } else if (data.html) { %>
|
||||
<%= data.html %>
|
||||
<% } else if (data.item) { %>
|
||||
<%= data.item %>
|
||||
<% } else { %>
|
||||
<%= '未找到渲染数据' %>
|
||||
<% } %>
|
||||
`
|
||||
};
|
||||
|
||||
export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
wrapperRef: React.RefObject<HTMLDivElement> = React.createRef();
|
||||
intervalTimeout: number;
|
||||
|
@ -207,7 +236,8 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
|||
controls,
|
||||
controlsTheme,
|
||||
placeholder,
|
||||
data
|
||||
data,
|
||||
name
|
||||
} = this.props;
|
||||
const {
|
||||
options,
|
||||
|
@ -215,34 +245,6 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
|||
current,
|
||||
nextAnimation
|
||||
} = this.state;
|
||||
const defaultSchema = {
|
||||
type: 'tpl',
|
||||
tpl: `
|
||||
<% if (data.hasOwnProperty('image')) { %>
|
||||
<div style="background-image: url(<%= data.image %>)" class="image <%= data.imageClassName %>"></div>
|
||||
<% if (data.title) { %>
|
||||
<div class="title <%= data.titleClassName %>"><%= data.title %></div>
|
||||
<% } if (data.description) { %>
|
||||
<div class="description <%= data.descriptionClassName %>"><%= data.description %></div>
|
||||
<% } %>
|
||||
<% } else if (data.hasOwnProperty('html')) { %>
|
||||
<%= data.html %>"
|
||||
<% } else if (data.image) { %>
|
||||
<div style="background-image: url(<%= data.image %>)" class="image <%= data.imageClassName %>"></div>
|
||||
<% if (data.title) { %>
|
||||
<div class="title <%= data.titleClassName %>"><%= data.title %></div>
|
||||
<% } if (data.description) { %>
|
||||
<div class="description <%= data.descriptionClassName %>"><%= data.description %></div>
|
||||
<% } %>
|
||||
<% } else if (data.html) { %>
|
||||
<%= data.html %>
|
||||
<% } else if (data.item) { %>
|
||||
<%= data.item %>
|
||||
<% } else { %>
|
||||
<%= '未找到渲染数据' %>
|
||||
<% } %>
|
||||
`
|
||||
}
|
||||
|
||||
let body:JSX.Element | null = null;
|
||||
let carouselStyles: {
|
||||
|
@ -278,7 +280,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
|||
return (
|
||||
<div className={cx('Carousel-item', animationName, animationStyles[status])}>
|
||||
{render(`${current}/body`, itemSchema ? itemSchema : defaultSchema, {
|
||||
data: createObject(data, isObject(option) ? option : {item: option})
|
||||
data: createObject(data, isObject(option) ? option : {item: option, [name]: option})
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue