Closed
Description
在做分页组件时,我想在设置curIndex的时候对其进行校验,但我不想在watch去处理,因为这样会触发多次,但是this的指向是window,是否有可以将其指向到$vm呢?
props:{
// 当前页
curIndex: {
type: Number,
default: 0,
coerce: function (val) {
//this --> window
//i want --> $vm
if( val < 0 ){
val = 0;
}else if(val>=this.total){
val = this.total - 1;
}
return val;
}
}
}
Metadata
Metadata
Assignees
Labels
No labels