mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 20:48:49 +08:00
修改验证Carousel中options是否改变的方式
This commit is contained in:
parent
03762d14ad
commit
3995aca5c4
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import Transition, {ENTERED, ENTERING, EXITING} from 'react-transition-group/Transition';
|
import Transition, {ENTERED, ENTERING, EXITING} from 'react-transition-group/Transition';
|
||||||
import {Renderer, RendererProps} from '../factory';
|
import {Renderer, RendererProps} from '../factory';
|
||||||
import {resolveVariable} from '../utils/tpl-builtin';
|
import {resolveVariable} from '../utils/tpl-builtin';
|
||||||
import {autobind, createObject, isObject} from '../utils/helper';
|
import {autobind, createObject, isObject, isArrayChilrenModified} from '../utils/helper';
|
||||||
import {leftArrowIcon, rightArrowIcon} from '../components/icons';
|
import {leftArrowIcon, rightArrowIcon} from '../components/icons';
|
||||||
|
|
||||||
const animationStyles: {
|
const animationStyles: {
|
||||||
@ -91,7 +91,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
|||||||
componentWillReceiveProps(nextProps:CarouselProps) {
|
componentWillReceiveProps(nextProps:CarouselProps) {
|
||||||
const currentOptions = this.state.options;
|
const currentOptions = this.state.options;
|
||||||
const nextOptions = nextProps.value || nextProps.options || resolveVariable(nextProps.name, nextProps.data) || [];
|
const nextOptions = nextProps.value || nextProps.options || resolveVariable(nextProps.name, nextProps.data) || [];
|
||||||
if (JSON.stringify(currentOptions) !== JSON.stringify(nextOptions)) {
|
if (isArrayChilrenModified(currentOptions, nextOptions)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
options: nextOptions
|
options: nextOptions
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user