我正在尝试创建一个引用生成器,但是当尝试读取变量时,它会一直返回undefined。我也使用了一个linter来帮助我,因为我在括号内走,这给了我同样的错误。
public class ItemsController
{
IQueryHandler<PagedQuery<GetAllItemsQuery, Item>, Paged<Item>> handler;
public ItemsController(
IQueryHandler<PagedQuery<GetAllItemsQuery, Item>, Paged<Item>> handler)
{
this.handler = handler;
}
public ActionResult Index(PagedQuery<GetAllItemsQuery, Item> query)
{
return View(this.handler.Handle(query));
}
}
var quote = document.getElementById("quote-here");
var creator = document.getElementById("subscript");
var quoteButton = document.getElementById("quote-btn");
var arr = [
{"qoute": "Don't cry because it's over, smile because it happened.", "creater": "Dr.Seuss"},
{"qoute": "Be yourself; everyone else is already taken.", "creater": "Oscar Wilde"},
{"qoute": "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.", "creater": "Albert Einstein"},
{"qoute": "So many books, so little time.", "creater": "Frank Zappa"},
{"qoute": "Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.", "creater": "Bernard M. Baruch"},
{"qoute": "A room without books is like a body without a soul.", "creater": "Marcus Tullius Cicero"},
{"qoute": "You only live once, but if you do it right, once is enough.", "creater": "Mae West"},
{"qoute": "Be the change that you wish to see in the world.", "creater": "Mahatma Gandhi"},
{"qoute": "If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.", "creater": "J.K. Rowling, Harry Potter and the Goblet of Fire"},
{"qoute": "Friendship ... is born at the moment when one man says to another 'What! You too? I thought that no one but myself . . .'", "creater": "C.S. Lewis, The Four Loves"},
{"qoute": "No one can make you feel inferior without your consent.", "creater": "Eleanor Roosevelt, This is My Story"},
{"qoute": "If you tell the truth, you don't have to remember anything.", "creater": "Mark Twain"},
{"qoute": "There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.", "creater": "Albert Einstein"}
];
function rando(min, max) {
"use strict";
return Math.floor(Math.random() * (max - min) + min);
}
function generate() {
"use strict";
var x = rando(0, 13);
quote.innerHTML = arr[x].quote;
creator.innerHTML = "- " + arr[x].quote;
}
quoteButton.addEventListener('click', generate);
答案 0 :(得分:1)
这是一个错字,你在数组中写了qoute。
答案 1 :(得分:0)
这是一个错误的错误。
var quote = document.getElementById("quote-here");
var creator = document.getElementById("subscript");
var quoteButton = document.getElementById("quote-btn");
var arr = [
{qoute: "Don't cry because it's over, smile because it happened.", creater: "Dr.Seuss"},
{qoute: "Be yourself; everyone else is already taken.", creater: "Oscar Wilde"},
{qoute: "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.", creater: "Albert Einstein"},
{qoute: "So many books, so little time.", "creater": "Frank Zappa"},
{qoute: "Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.", creater: "Bernard M. Baruch"},
{qoute: "A room without books is like a body without a soul.", creater: "Marcus Tullius Cicero"},
{qoute: "You only live once, but if you do it right, once is enough.", creater: "Mae West"},
{qoute: "Be the change that you wish to see in the world.", creater: "Mahatma Gandhi"},
{qoute: "If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.", creater: "J.K. Rowling, Harry Potter and the Goblet of Fire"},
{qoute: "Friendship ... is born at the moment when one man says to another 'What! You too? I thought that no one but myself . . .'", creater: "C.S. Lewis, The Four Loves"},
{qoute: "No one can make you feel inferior without your consent.", creater: "Eleanor Roosevelt, This is My Story"},
{qoute: "If you tell the truth, you don't have to remember anything.", creater: "Mark Twain"},
{qoute: "There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.", creater: "Albert Einstein"}
];
function rando(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
function generate() {
var x = rando(0, 13);
console.log(arr[x].qoute)
quote.innerHTML = arr[x].qoute;
creator.innerHTML = "- " + arr[x].creater;
}
quoteButton.addEventListener('click', generate);