一、vue
-
element ui
select 详解:https://www.jianshu.com/p/4a83a6d8136c -
forEach(): 中的return 不能终止循环,更不能终止函数。
getId(onedeviceId){
var final
this.deviceIds.forEach((point)=>{
if(point.deviceId===onedeviceId){
console.log('point.groupName',point.groupName)
//return point.groupName
final=point.groupName
}
})
return final
- vue 中的setInterval与clearInterval
问题很多,一个是vue中的interval重写了interval,setInterval返回的是一个值,消除需要把值传入clearInterval中。多打印下就理解了。
定时任务多的话建议用一个数组保存返回值,销毁方便。
建议使用window.setinterval
if ( this.intervalList.length !== 0){
this.intervalList.forEach((item,index)=>{
window.clearInterval(item)
console.log('item',item)
})
this.intervalList = []
this.interval = 0
}
this.interval = window.setInterval(()=>{
// this.getEchart(this.echartId)
// this.xData=this.x2Data
this.getEchart($event)
// console.log(" this.interval ", this.interval )
},2000);