北京网站建设最便宜的公司哪家好,flash网站源码 免费,二元期货交易网站开发,建电影网站赚钱挣钱吗效果展示 一、需求背景#xff1a;
# vue3 项目涉及很多图表加载、表格加载 #考虑手写一个动态加载组件
二、实现思路
通过一个加载状态变量#xff0c;通过v-if判断#xff0c;加载状态的变量等于哪一个#xff0c;动态加载组件内部就显示的哪一块组件。
三、实现效果…效果展示 一、需求背景
# vue3 项目涉及很多图表加载、表格加载 #考虑手写一个动态加载组件
二、实现思路
通过一个加载状态变量通过v-if判断加载状态的变量等于哪一个动态加载组件内部就显示的哪一块组件。
三、实现效果 四、代码
(一)、封装组件
templateview classloadding_contaniers v-ifloadState 1view classloading_imgimage src/static/images/smartCabin/loadingImg/isLoading_bg.png //viewview classimgTitle加载中text iddot.../text/view/viewview classloadding_contaniers v-else-ifloadState 2view classloading_imgimage src/static/images/smartCabin/loadingImg/isErr_bg.png //viewview classimgTitle请求失败请重新加载/view/viewview classloadding_contaniers v-else-ifloadState 3view classloading_imgimage src/static/images/smartCabin/loadingImg/isNone_bg.png /!-- image:srcgetAssetsFile(props.noticeTip 暂无数据? smartCabin/loadingImg/isNone_bg.png: smartCabin/loadingImg/isErr_bg2.png)/ --/viewview classimgTitle{{ noticeTip }}/view/viewview classloadding_sucess v-elseslot /slot/view
/templatescript
export default {props: {// 1:加载中 2加载失败 3暂无数据 4加载成功loadState: Number,noticeTip: {type: String,default: 暂无数据,},},
};
/scriptstyle langscss
.loadding_contaniers {width: 100%;height: 100%;display: flex;flex-direction: column;align-items: center;justify-content: center;.loading_img {image {width: 260rpx;height: 260rpx;}}.imgTitle {flex: 1;height: 0;color: #757575;#dot {display: inline-block;width: 1.5em;vertical-align: bottom;overflow: hidden;animation: dotting 0.5s infinite step-start;}keyframes dotting {0% {width: 0;margin-right: 1.5em;}33% {width: 0.5em;margin-right: 1em;}66% {width: 1em;margin-right: 0.5em;}100% {width: 1.5em;margin-right: 0;}}}
}
.loadding_sucess {width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;
}
/style (二)、组件传参 h5使用 LoaddING :loadState4 :noticeTip当loadState是成功的时候view classmyContentimagesrc/static/images/energy/elePower/receiving_power.png//view
/LoaddING web端使用 LoaddING :loadStatedata.isFinish :noticeTipdata.isTips!-- 插槽组件 --ewClickLine:yAxisUnitechartData2.unit:seriesColorechartData2.color:legend{ show: true, x: 80% }:seriesNameechartData2.name:seriesTypeechartData2.chartSeriesType:xAxisValueechartData2.lineXAxisValue:numsechartData2.lineNums/ewClickLine
/LoaddING