vue中如何带参数打开新的html
在项目中我们会有跳转到指定html页面的需求,在vue组件中:data(){return {list:[{name: 'test1',videoUrl:'ddd.mp4'}]}},methods: {currVideo(data){window.open("/static/news.html?videoS
·
在项目中我们会有跳转到指定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>
更多推荐
已为社区贡献29条内容
所有评论(0)