filterScrollTo() {
const parent = document.querySelector('#quoteitemcon');
const child = document.getElementsByClassName('quote-con');
console.log('parent', parent, child);
parent.scrollTo({
top: child[child.length - 1].offsetTop,
behavior: 'smooth'
});
},
// 删除条件
deleteQuote(index, fieldIndex) {
this.tableColumns[index].fieldInfo.quoteRelationship.splice(
fieldIndex,
1
);
console.log(
'index',
index,
fieldIndex,
this.tableColumns[index].fieldInfo.quoteRelationship
);
// this.filterData.splice(index, 1);
this.$nextTick(() => {
this.filterScrollTo();
});
},
// 添加同理,也需要调
this.$nextTick(() => {
this.filterScrollTo();
});
切记:同一个页面多个地方使用或者多个页面使用filterScrollTo,记得把父子组件的id名称换掉
<el-col :span="24" class="quote-item-con" id="quoteitemcon">
<label
style="margin-bottom: 10px; display: block"
v-show="fieldOption.length > 0"
>引用条件</label
>
<div
v-for="(quoteItem, fieldIndex) in column.fieldInfo
.quoteRelationship"
:key="fieldIndex"
class="quote-con"
>
<i
class="el-icon-close"
@click="deleteQuote(index, fieldIndex)"
></i>
<el-form-item
label=""
prop="relationshipFiledName"
style="padding: 0 5px; margin-bottom: 0"
class="rule-small-item"
>
<el-select v-model="quoteItem.relationshipFiledName">
<el-option
v-for="item in fieldOption"
:key="item.id"
:label="item.fieldRemarks"
:value="item.fieldName"
></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
标签:index,parent,filterScrollTo,条到,fieldIndex,添加,child,滑动
From: https://www.cnblogs.com/sinceForever/p/17633677.html