<template>
<div>
<p class="aaa"> ksjdfgbhkjsdfp>
<el-collapse v-model="activeName"
@change="handleChange"
accordion
>
<template v-for="item in items">
<el-collapse-item
:title="item.title"
:name="item.id"
:key="item.id">
<div :id="item.id" added="0">
<p :id="item.id+'ing'"> 正在努力加载数据中,请稍后p>
div>
el-collapse-item>
template>
el-collapse>
div>
template>
<script>
export default {
data() {
return {
activeName: "",
items:[
{"title":"A","id":"123"},
{"title":"B","id":"456"},
{"title":"C","id":"789"}
],
index:0
};
},
methods: {
handleChange(val) {
if (val!=""){
console.log("展开"+val)
var area = document.getElementById(val);
if (area.getAttribute("added")==="0"){
setTimeout(()=>{
document.getElementById(val+'ing').remove();
var p = document.createElement("p");
p.className="aaa";
p.innerText=(++this.index)+":"+new Date().toLocaleString( );
area.appendChild(p);
area.setAttribute("added","1");
},
3000)
}
}else{
console.log("折叠")
}
}
}
}
</script>
<style>