2016-10-28 4 views
0

riotjs 라이브러리를 사용하고 있으며 "주석 목록"과 "주석"이라는 두 개의 태그가 있습니다.Riotjs 중첩 태그 옵션이 정의되지 않았습니다.

코멘트리스트 :

<comment-list> 
    <div each={com in comments} > 
     <comment level={opts.level} comment={com} type={opts.level == 0 ? "parent" : "child"} ctype={commentType}></comment> 
    </div> 

    <div show={opts.level == 0}> 
     <a id="load-trigger" onclick={fetchMore}>Moar comments</a> 
    </div> 


    var self = this; 
    self.commentType = (self.opts.level === 0 ? "parent" : "child"); 
</comment-list> 

및 의견

<comment> 
    ... some html ... 

    <div class="row" if={opts.level == 0}> 
     <div class="col s11 offset-s1 m11 offset-m1 l11 offset-l1" style="padding-left: 0;"> 
     <comment-list level={1} fetchMore={fetchMore}></comment-list> 
     </div> 
    </div> 
</comment> 

주석 - list.tag가 초기화되는 댓글이 레벨 값을 전달하도록되어 = 0 레벨 .tag. 문제는 내가 opts.levelcomment.tag에 액세스하려 할 때 '정의되지 않음'입니다. ctype에 대해서도 마찬가지입니다. 유형의 opts.level이 comment-list.tag이 정의되지 않은 것처럼 항상 "하위"입니다.

Ps : comment-list가 null이거나 'undefined'로 간주되는 것으로 생각하지 않습니다. 예를 들어 값 1과 동일한 동작을합니다. 값을 직선으로 잘못 전달합니까? opts 개체에서?

+0

정확히 무엇을 달성하려고하는지 모르지만, 몇 가지 팁. 태그를 올바르게 마운트합니다.이 경우 일부 초기 값을 추가했습니다. 'riot.mount ('comment-list', {level : 0, comments : [{level : 0}, {level : 1}])' 처음에는 옵트 머트 리얼의 레벨에 액세스하고 있습니까, 또는 반복하고있는 아이에게 레벨에 액세스하려고하고 있습니까? 각각의 내부에서는 하위 컨텍스트에 있으므로 부모를 원할 경우 parent.opts.level을 수행해야합니다. 다음은 http://plnkr.co/edit/7znf8HJh1wnpX9bjrxIX?p=preview의 간단한 예입니다. – vitomd

답변

0

각각은 하위 범위를 생성하므로 부모를 볼 필요가 있습니다.

변경 {opts.level}

그래서 <comment-list> 현재 범위, 그리고 당신의 each={com in comments} 아이의 범위를 생성 {parent.opts.level}합니다. opts.level은 현재/부모에 속해 있으며 반복 된 개별 범위에 속하지 않습니다.

https://github.com/riot/riot/issues/1720

여기에 내가이 정확한 질문을 위해 올해 초 제기 된 GitHub의 문제입니다.