在项目中我们会有跳转到指定html页面的需求,

在vue组件中:

<div  v-for = "(item,index) in list" :key = "index" @click.native="currVideo(item.videoUrl)"></div>

data(){

 return {

 list:[

 {

 name: 'test1',

videoUrl: 'ddd.mp4'

}

]

}

},

methods: {

 currVideo(data){

 window.open("/static/news.html?videoSource="+data)

}

}

 

//在新的vue组件中

<video>

 <source type="video/mp4" id="currentSource">

</video>

<script>

 var string = window.location.search;

var str = string.split('=')[1];

document.getelementById('currentSource').setAttribute("src","../video"+str);

 

</script>

Logo

前往低代码交流专区

更多推荐