美文网首页
组件传值

组件传值

作者: 洛禾sunshime | 来源:发表于2019-03-04 13:36 被阅读0次
    <video
          ref="video"
          id="video"
          :src="videoUrl"
          playsinline="true"
          webkit-playsinline="true"
          @canplaythrough="playThrough"
        ></video>
      </div>
      <div class="play-video" v-show="staute">
        <div class="v-img" @click="clickVideo">
          <img src="../../common/images/play.png" alt>
          <span>00'{{Math.floor(timer-0)}}"</span>
        </div>
      </div>
      <div class="progress-bar" v-show="!staute">
        <div class="left-bar" @click="clickChangeVideo">
          <div class="stop-bar" v-show="stautepaly">
            <img src="../../common/images/stop-bar.png" alt>
          </div>
        </div>
      </div>    

在组件外部修改视频的路径

data() {
    return {
      videoUrl: "../../../static/video/video.mp4",
      staute: true,
      stautepaly: true
    };
// 命名不一样的名字
 props: {
   src: {
     type: String
   },
   status:{
     type:Boolean
   },
   statuspaly: {
     type:Boolean
   }
 },
 watch:{
   status(value){
     this.staute = this.status;
   },
   statuspaly(value) {
     this.stautepaly = this.statuspaly;
   }
 },
mouted(){
   let that = this;
   that.videoUrl = that.src;
   that.staute = that.status;
   that.stautepaly = that.statuspaly;
}

用到的页面

<Video :src="'../../../static/video/cat.mp4'" :status="status" :stautepaly="stautepaly"></Video>
 data() {
    return {
      stautepaly: true,
      status:true,
      stautepaly: true,
    };
  }

之后修改就跟在这个页面修改其他值一样的修改即可

相关文章

  • Vue - 传值

    Vue 传值有两种:1)父组件向子组件传值(属性传值,Prop传值)2)子组件向父组件传值 一、父组件向子组件传值...

  • 组件之间的传值

    组件之间的传值,包括父子组件传值,兄弟组件之间的传值,其中父子组件包括父组件向子组件传值和子组件向父组件传值,现在...

  • Vue_组件间传值

    1、父组件传值给子组件2、子组件传值给父组件 1、父组件传值给子组件 2、子组件传值给父组件

  • 2018-09-05

    组件传值问题 父组件给子组件传值应该使用props。子组件要给父组件传值,需要调用父组件传递的方法。props传值...

  • vue2.0 父子组件传值

    父组件传值给子组件 子组件 子组件通过 props 接收值 父组件 父组件通过标签属性传值 子组件传值给父组件 子...

  • Vue父子组件通信和双向绑定

    本篇文章主要介绍父子组件传值,组件的数据双向绑定。 1. 基础父子组件传值 父子组件传值,这是Vue组件传值最常见...

  • (Vue-cli)六、组件间传值(组件间传值&全局状态管理sto

    六、组件间传值 1.父子组件传值 (1) 父传子 父组件向子组件传值,可以通过绑定属性传值;子组件通过props接...

  • vue2.0的三种常用传值方式,并且如何实现?

    vue2.0 组件传值方式有三种:父组件向子组件传值,子组件向父组件传值,非父子组件传值 : 父传子: 首先现在父...

  • Vue.js父子组件传值

    父组件向子组件传值: 子组件向父组件传值:

  • Vue.js父子组件和非父子组件间的传值通信

    [toc] 父子组件的传值通信 父组件向子组件传值 父组件: 子组件: 子组件向父组件传值 Note 子组件不能直...

网友评论

      本文标题:组件传值

      本文链接:https://www.haomeiwen.com/subject/ijzbuqtx.html