在 vue.js 中拉伸嵌入的 vimeo 失败

acr*_*ene 2 vimeo vue.js

我在 vue.js 中使用vue-vimeo-player来嵌入 vimeo 视频。我想将视频拉伸到屏幕的整个宽度并使其具有响应性,但我无法使其拉伸。

这是 vue 中的一个简单组件来说明问题。我当然可以更改玩家高度和玩家宽度道具来更改大小,但我无法使其 100% 响应。我认为我的 css 中的 vimeo 类应该解决这个问题,但没有运气。

任何提示将非常感激!

<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> 

Run Code Online (Sandbox Code Playgroud)

Den*_*soi 5

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> 
Run Code Online (Sandbox Code Playgroud)

笔记:

您可能仍然需要处理 css 宽度/样式