我正在使用完全修补的Visual Studio 2013。我有一个我刚刚创建的网站,并试图使用jquery,jqueryui和jsrender。我也尝试使用TypeScript。在ts文件中,我收到如下错误:属性在类型“{}”上不存在
属性'fadeDiv'在类型'{}'上不存在。
我有正确的引用,我认为jquery,jqueryui和jsrender打字稿..但从我读过的这看起来像一个d.ts问题。希望有人能帮助我。
在JavaScript中没有错误,但我不想让Visual Studio说有错误,如果我可以帮助它。这两次fadeDiv在javascript中都提到了它下面有一条红线,并且这两个错误都与上面相同。
感谢 香
/// <reference path="../scripts/typings/jquery/jquery.d.ts" />
/// <reference path="../scripts/typings/jqueryui/jqueryui.d.ts" />
/// <reference path="typings/jsrender/jsrender.d.ts" />
var SUCSS = {};
$(document).ready(function() {
SUCSS.fadeDiv();
});
SUCSS.fadeDiv = function() {
var mFadeText: number;
$(function() {
var mFade = "FadeText";
//This part actually retrieves the info for the fadediv
$.ajax({
type: "POST",
//url: "/js/General.aspx/_FadeDiv1",
url: "/js/sucss/General.aspx/_FadeDivList",
//data: "{'iInput':" + JSON.stringify(jInput) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, status, error) {
// Show the error
//alert(xhr.responseText);
},
success: function (msg) {
mFadeText = msg.d.Fade;
// Replace the div's content with the page method's return.
if (msg.d.FadeType == 0) {//FadeDivType = List
var template = $.templates("#theTmpl");
var htmlOutput = template.render(msg.d);
$("[id$=lblFadeDiv]").html(htmlOutput);
}
else {//FadeDivType = String
$("[id$=lblFadeDiv]").html(msg.d.FadeDivString);
}
},
complete: function() {
if (mFadeText == 0) {
$("[id$=lblFadeDiv]").fadeIn('slow').delay(5000).fadeOut('slow');
}
}
});
});
对于那些谁可能会读这以后..的SUCSS的命名空间。在打字稿看来我本来想要做这样的事情。
$(document).ready(function() {
SUCSS.fadeDiv();
});
module SUCSS {
export function fadeDiv() {};
};
所以该功能通过使用出口的公开,我可以通过与SUCSS.fadeDiv呼唤出来的()调用SUCSS.fadeDiv对页面加载运行; 希望能有所帮助。
你似乎缺少至少收盘'}'梅开二度,也许还有其他的代码。 –
您需要将此代码缩减为一个独立的示例,以便人们可以真正重现问题。就目前而言,你有很多使用的变量没有定义,所以我们只能猜测它们的类型。 –