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

update:更新

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