点击按钮添加视频video 新增类名 设置状态
html 代码
<p id="demo"></p>
<button @click="myFunction('https://vd3.bdstatic.com/mda-nerfsvgshsy71kge/sc/cae_h264/1653565467811258541/mda-nerfsvgshsy71kge.mp4?v_from_s=hkapp-haokan-nanjing&auth_key=1653574971-0-0-070cded1cabf9e8b2eb1dfc974e0033f&bcevod_channel=searchbox_feed&pd=1&cd=0&pt=3&logid=3171249120&vid=8038329417376972164&abtest=101830_2-102148_2-17451_2-3000232_1-3000233_3&klogid=3171249120')">试一下</button>
或者
<button onclick="myFunction('https://vd3.bdstatic.com/mda-nerfsvgshsy71kge/sc/cae_h264/1653565467811258541/mda-nerfsvgshsy71kge.mp4?v_from_s=hkapp-haokan-nanjing&auth_key=1653574971-0-0-070cded1cabf9e8b2eb1dfc974e0033f&bcevod_channel=searchbox_feed&pd=1&cd=0&pt=3&logid=3171249120&vid=8038329417376972164&abtest=101830_2-102148_2-17451_2-3000232_1-3000233_3&klogid=3171249120')">试一下</button>
script 代码
function myFunction(url) {
console.log("123");
var x = document.createElement("video");
console.log(x);
// 'video-js'
x.classList.add('vjs-default-skin', 'vjs-big-play-centered');
x.setAttribute("width", "100%");
x.setAttribute("height", "220px");
x.setAttribute("controls", "controls");
x.setAttribute("preload", "auto");
x.setAttribute(":poster", "posterImg");
x.setAttribute("src", url);
// document.getElementById("demo").innerHTML = "您应该在 video 元素中使用 source 元素。";
document.getElementById('demo').appendChild(x);
}