문제

Working example with global var:

var example_var = 'global var example';

var x = function(){
    var var_name = 'example_var';
    alert('Global var value is: ' + window[var_name]);
}

How can I do same thing with a local variable? Like this (not working example):

var x = function(){
    var example_var = 'Local var example';
    var var_name = 'example_var';
    alert('Local var value is: ' + window[var_name]);
}
도움이 되었습니까?

해결책

You don't want to use eval; a locally scoped object might be your best option:

var x = function(){
    var self = {};
    self.example_var = 'Local var example';

    var var_name = 'example_var';

    alert('Local var value is: ' + self[var_name]);
}

다른 팁

나는 마침내 문제를 해결하기에 충분히 깊이 나아갔습니다.

사람들의 결과 웹 파트가있는 디자인에 따라 Microsoft에 따르면 핵심 결과 웹 파트를 대신 사용할 수 있습니다.

"Apparently, the issue is with the People Results web part. If you remove it and add the Core Results web part instead, point it at the People scope and configure it the same way, it should work."
.

아마도 더 나은 해결 방법이 있습니다.

크롤링 속성에 대한 매핑을 '컨트롤러 -> 응용 프로그램 관리 -> 서비스 응용 프로그램 관리 -> 서비스 응용 프로그램 -> 메타 데이터 속성 관리 -> 관리 응용 프로그램 -> 메타 데이터 속성에 대한 매핑 추가로 이동하십시오.

및 그 크롤링 속성에 맵핑됩니다.증분 크롤링을 실행하십시오.그게 작동해야합니다.

Excel 파일이 Internet Explorer (인터넷 옵션)의 신뢰할 수있는 영역에있는 SharePoint 사이트의 URL을 추가합니다.이것은 사용자 B 워크 스테이션에서 수행되어야합니다.

방화벽 정책, 안티 바이러스 등과 같은 다른 유사한 보안 설정을 확인하십시오.

At the moment there are two solutions to this problem.
1. eval(), but i really don't like to use evil()
2. we can change variable declaration from var to this:

var x = function(){
    this.example_var = 'this.var example';
    this.var_name = 'example_var';
    alert('Local variable value is: ' + this[var_name]);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top