vue.js - stretch embedded vimeo in vue.js fails
问题描述
Im using the vue-vimeo-player in vue.js for embedding vimeo video. I want to stretch the video over the full width of the screen and make it responsive but I cannot make it to stretch.
Here is a simple component in vue illustrating the problem. I can of course change the player-height and player-width props to change the size but I cannot make it 100% and responsive. I thought the vimeo class in my css should solve this but no luck.
Any hint would be very much apreciated!
<template>
<vimeo-player
class="vimeo"
ref="player"
:video-id="videoID"
@ready="onReady"
:autoplay="true"
:player-height="320"
:player-width="640"
loop="1"
></vimeo-player>
</template>
<script>
export default {
data() {
return {
videoID: "224712377",
options: {},
playerReady: false
};
},
methods: {
onReady() {
this.playerReady = true;
},
play() {
this.$refs.player.play();
},
stop() {
this.$refs.player.stop();
}
}
};
</script>
<style lang="scss">
.vimeo {
left: 0;
top: 0;
height: 100%;
width: 100%;
// max-height: 200px;
position: absolute;
}
</style>
解决方案
vue 组件只是 vimeo 播放器的包装器。
经过进一步调查,
需要vue-vimeo-player
播放vimeo
器 npm 包。
vue-vimeo 播放器
@Vimeo/player
有一个responsive
默认设置为 false 的选项。
github/vimeo/播放器
您可以通过vue-vimeo-player
道具options
通过
这样
<template>
<vimeo-player
class="vimeo"
ref="player"
:options="{ responsive: true }"
:video-id="videoID"
@ready="onReady"
:autoplay="true"
:player-height="320"
:player-width="640"
loop="1"
></vimeo-player>
</template>
<style lang="scss">
.vimeo {
left: 0;
top: 0;
height: 100%;
width: 100%;
// max-height: 200px;
position: absolute;
}
</style>
笔记:
您可能仍需要处理 css 宽度/样式
推荐阅读
- javascript - 如果我在 nextjs 中使用组件作为标记,则不会调用 getServerSideProps 或 getStaticProps
- javascript - 动态创建的 html 表格数据未按预期顺序显示
- html - li 后如何不断线并保持子弹
- python - 从在 Ubuntu 上运行的 Python 将文件保存在 Windows 文件夹中
- apache - apache2 www到非www重定向不起作用
- java - Json Schema 验证不适用于嵌套对象中的 Draft 7 所需属性,具体取决于值
- javascript - nvm 与 npm 配置“前缀”反应不兼容
- amazon-web-services - 如何在 sh 脚本中使用 groovy 变量的输出?
- java - 更新了问题 - 尽管放入了 try catch,但获取过时的元素异常,等到异常元素可见
- notifications - 每次出现新日志时都会发出 Grafana 警报通知。无需提醒