我有一个非常标准的控制器:
这是控制器定义(一些依赖注入,但标准):
public class SeriesController : Controller
{
private readonly IHostingEnvironment _env;
public SeriesController(IHostingEnvironment env)
{
_env = env;
}
[HttpGet("/series/{id:int?}/{title?}")]
public IActionResult Index(int id, string title)
{
if (id > 0)
{
var populateSeriesItem = new PopulateSeriesItem(_env, new SqlConnection());
var seriesItem = populateSeriesItem.GenerateSeriesItem(id);
//...
Run Code Online (Sandbox Code Playgroud)
如果id不存在(或0),则显示所有记录;如果为 1 或更大,则显示一条记录。(这就是客户想要的!)
我这样称呼它:
https://localhost/series/3/title
或者
但问题是 id 始终为 0(并且标题为 null)。
如果我将其输入到 URL 栏中或手动指定 id(即 /series?id=3),就会出现这种情况
我只是不明白我错过了什么。
完全相同的设置与不同的控制器完美配合。
[HttpGet("/books/{id:int?}/{title?}")]
public ActionResult Index(int id, string title)
{
if (id > 0)
{
var populateBookItem = …Run Code Online (Sandbox Code Playgroud) 我正在修改一个JQuery脚本来淡化div中的元素(在循环中).
这是脚本的一部分:
var fadeDuration = 2000;
var displayTime = 4000;
var currentIndex = 1;
var nextIndex = 1;
$(document).ready(function () {
$('ul.slideshow li').css({opacity: 0.0});
$("'ul.slideshow li:nth-child(" + nextIndex + ")'").addClass('show').animate({opacity: 1.0}, fadeDuration);
var timer = setInterval("nextSlide()", displayTime);
});
Run Code Online (Sandbox Code Playgroud)
如果我使用JQuery 1.5,这没有问题,但如果我使用JQuery 1.12.0或JQuery 2.2它会失败,给我这个错误:
"无法在'Element'上执行'querySelectorAll':'*,:x'不是有效的选择器."
它在函数的第二行失败:
$("'ul.slideshow li:nth-child(" + nextIndex + ")'").addClass('show').animate({opacity: 1.0}, fadeDuration);
Run Code Online (Sandbox Code Playgroud)
我是JQuery的新手,我正在使用它作为学习练习,但我很困惑,不知道如何开始调试问题(假设它适用于JQuery 1.5).
任何建议非常感谢!