<template>
<div class="scroll-container" id="scroll-container">
<div class="v-scroll">
<div class="content">
<slot></slot>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {};
},
mounted() {
const container = document.getElementById("scroll-container");
const resizeObserver = new ResizeObserver((entries) => {
for (let entry of entries) {
const { width, height } = entry.contentRect;
console.log(width, height, container.querySelector(".v-scroll"));
try {
container.querySelector('.v-scroll').style.width=height+'px';
container.querySelector('.v-scroll').style.height=width+'px';
container.querySelector('.v-scroll').style.transform=`translateY(${height}px) rotate(-90deg)`
container.querySelector('.content').style.width=width+'px';
container.querySelector('.content').style.height=height+'px';
container.querySelector('.content').style.left=height+'px';
} catch (error) {
}
}
});
resizeObserver.observe(container);
},
methods: {
handleChange({ width, height }) {
console.log(width, height);
},
},
};
</script>
<style scoped lang="scss">
.scroll-container {
width: 100%;
height: 100%;
.v-scroll {
position: relative;
overflow: auto;
transform-origin: left top;
// border: 1px solid red;
&::-webkit-scrollbar{
display: none;
}
}
.content{
position: absolute;
top: 0;
transform-origin: left top;
// border: 1px solid red;
transform:rotate(90deg)
}
}
</style>
<template>
<div class="viewbox">
<scrollcom>
<div style="white-space: nowrap;
width: max-content;">
<div v-for="item in 10" :key="item" style="float:left">
{{ item }}
<img src="@/assets/img/01.png" alt="">
</div>
</div>
</scrollcom>
</div>
</template>
<script>
import scrollcom from '@/components/scroll'
export default {
components:{scrollcom}
}
</script>
<style scoped>
.viewbox{
width: 100vw;
height: 500px;
background: #ccc;
}
</style>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探