问题描述
我目前正在开发 ASP.NET MVC 应用程序,但它不显示任何视频。我正在尝试使用 VenoBox 来设计我的视频库,如本教程所示:
https://www.youtube.com/watch?v=mrvWHfH5pm0
VenoBox 是一个包,可让您对视频、图像、iframe 等组进行样式化。但我的视图不会在屏幕上显示任何内容。我有一个名为“视频”的模型,我将视频 ID 和 url 记住到数据库中,然后将列表中的视频发送到我的视图中。将 iframe 用于嵌入视频时,我的视频在屏幕上显示良好,但我仍然想用 VenoBox 风格化我的画廊,所以我必须使用“”链接而不是 iframe,但它不起作用。 这是我的观点:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<section class="content__section">
@foreach (var video in Model)
{
<div class="video">
<a class="venoBox" data-autoplay="true" data-vbtype="video" data-gall="mygallery" href="@video.Url"><i class="fas fa-play-circle"></i></a>
</div>
}
</section>
@section scripts{
<script>
$(document).ready(function () {
$('.venoBox').venoBox({
closeColor: '#f4f4f4',spinColor: '#f4f4f4',closeBackground: '#17191D',overlayColor: 'rgba(25,25,29,0.8)'
});
});
</script>
@Scripts.Render("~/bundles/lib")
}
这是 VenoBox 网站的链接: https://veno.es/venobox/ 在 bundles/lib 中,我保存了来自 VenoBox 的脚本。我也在使用 Chrome 来可视化我的项目。
解决方法
可能你的模型为空。
试试这个方法。
@model YourModel
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<section class="content__section">
@foreach (var video in Model)
{
<div class="video">
<a class="venobox" data-autoplay="true" data-vbtype="video" data-gall="myGallery" href="@video.Url"><i class="fas fa-play-circle"></i></a>
</div>
}
</section>
@section scripts{
<script>
$(document).ready(function () {
$('.venobox').venobox({
closeColor: '#f4f4f4',spinColor: '#f4f4f4',closeBackground: '#17191D',overlayColor: 'rgba(25,25,29,0.8)'
});
});
</script>
@Scripts.Render("~/bundles/lib")
}
这样视频变量会更有意义。