有什么办法在VueJS中的元素高度上设置观察者吗?
我正在尝试在搜索结果页面上修复过滤器部分。但是如果结果发生变化,则无法找到并取消过滤条件。
答案 0 :(得分:3)
在搜索结果返回数据之后,可以使用$ ref.yourElement.clientHeight获取高度。这样一来,您可以将高度设置为数据{}部分的一部分,然后从那里应用观察者。选中this example
Add-Type -AssemblyName Microsoft.Office.Interop.Excel
$excel = New-Object -ComObject Excel.Application
$excel.visible = $true
$workBook = $excel.Workbooks.Open("C:\Users\Garry\Desktop\test.xlsx")
$workSheet = $excel.WorkSheets.Item(1)
# not needed $xlLastCell = [Microsoft.Office.Interop.Excel.Constants]::xlLastColumn
$z = 1
Do {
$z
}
until ( $workSheet.Cells.Item(1, $z++).Value2 -eq $null )
答案 1 :(得分:1)
您可以使用ResizeObserver并将其集成到Vue组件中
function observeHeight() {
const resizeObserver = new ResizeObserver(function() {
console.log("Size changed");
});
resizeObserver.observe(document.getElementById('yourId'));
}
function changeHeight() {
var elem = document.getElementById('yourId');
elem.style = "height: 150px";
}
observeHeight();
changeHeight();
#yourId {
background-color: beige;
height: 100px;
}
<div id="yourId">
</div>