"creditText"의 줄에 "lbp가 정의되지 않았습니다"라는 이유는 무엇입니까? 이 설정 파일의 이전 속성을 어떻게 참조합니까? 당신의 도움이자바 스크립트 : 이전 속성이 정의되지 않았습니다.
1
A
답변
3
에 미리
var lbp = {
// Pertinant page properties, such as Author, Keywords, URL or Title
page: {
theURL: window.location.toString(),
},
// Configurable user defaults
defaults: {
creditText: lbp.page.theURL
}
}
덕분에 당신은하지 않습니다. lbp는 객체가 닫힐 때까지 현재 스코프의 심볼 테이블에 존재하지 않습니다.
var lbp = {
// Pertinant page properties, such as Author, Keywords, URL or Title
page: {
theURL: window.location.toString(),
}
}; // NOW you can reference lbp by name
lbp.defaults = {
creditText: lbp.page.theURL
};
0
선언의 마지막 괄호가 닫혀 있기 때문에 lbp 변수가 정의되지 않았습니다.
0
값을 lbp 변수에 할당하기 전에 정의중인 개체의 내용이 해석되고 있다고 나는 생각합니다. 나는 별도의 지시에 값을 할당하지 않고 원하는 것을 할 방법이 없다고 생각합니다.
var lbp = {};
// Pertinant page properties, such as Author, Keywords, URL or Title
lbp.page = { theURL: window.location.toString() };
// Configurable user defaults
lbp.defaults = { creditText: lbp.page.theURL };