提交 d2ab73df 编写于 作者: glod-money-money's avatar glod-money-money

update:更新

上级 ee10f192
......@@ -4,8 +4,8 @@
:interval="swipeConfig.interval">
<el-carousel-item v-for="item in swipeData" :key="item.key">
<div class="carousel-img-item">
<img class="app-carouse-img" v-if="item.type === 'img'" :src="item.imgPath" @error="imgError" />
<i v-else-if="item.type === 'icon'" :class="item.iconClass"></i>
<img class="app-carouse-img" v-if="item.type === 'img'" :src="item.value" @error="imgError" />
<i v-else-if="item.type === 'icon'" :class="item.value"></i>
</div>
</el-carousel-item>
</el-carousel>
......@@ -119,23 +119,57 @@ export default class AppCarousel extends Vue {
*/
@Watch('value', { immediate: true, deep: true })
public onValueChange(newVal: any, oldVal: any) {
//处理轮播图-静态数据
if (this.type === "STATIC_CAROUSEL") {
this.handleSwipData(newVal);
}
}
@Watch('data', { immediate: true, deep: true })
public onDataChange(newVal: any, oldVal: any) {
//处理轮播图-动态数据
if (this.type === "FIELD_CAROUSEL") {
if (this.value && typeof this.value === 'string') {
const swipeData = JSON.parse(this.value);
this.handleSwipData(swipeData);
const tempData = newVal[this.name]
if (tempData) {
if (typeof tempData === 'string') {
const swipeData = JSON.parse(this.value);
this.handDynaSwipData(swipeData);
} else if (tempData instanceof Array) {
this.handDynaSwipData(tempData);
}
}
//处理轮播图-静态数据
} else if (this.type === "STATIC_CAROUSEL") {
this.handleSwipData(this.value);
}
}
//处理动态轮播图数据
private handDynaSwipData(data: any[] = []) {
if (data && data.length > 0) {
this.swipeConfig = this.setSwipeConfig(data);
const tempData = data.filter((item: any) => {
return !Object.is(item.key, 'autoplay') && !Object.is(item.key, 'timespan');
})
this.swipeData = [];
tempData.forEach((item: any) => {
if (item.value) {
if (item.value.indexOf('fa fa-') < 0) {
if (!item.type) {
item.type = 'img';
}
} else if (!item.type) {
item.type = 'icon';
}
}
this.swipeData.push(JSON.parse(JSON.stringify(item)));
})
}
}
/**
* @description 处理轮播图数据
* @description 处理静态轮播图数据
* @memberof AppCarousel
*/
private handleSwipData(data: any) {
private handleSwipData(data: any[] = []) {
if (data && data.length > 0) {
const configItem = data.findIndex((item: any) =>
Object.is(item.key, "autoplay")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册