File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 77
88 export let comments = []
99 export let replying = []
10+ export let wordLimit = {
11+ nick: 0 ,
12+ mail: 0 ,
13+ site: 0 ,
14+ content: 0
15+ }
1016
1117 let D = $options
1218 const dispatch = createEventDispatcher ()
7783 <!-- 反之如果点击的是子评论的回复按钮,那么就将当前评论id传入,而(父评论id)pid为当前评论的(父评论id)pid -->
7884 <button class ="D-reply" on:click ={onReply (comment .id , comment .pid )}>{translate (' reply' )}</button >
7985 {#if replying === comment .id }
80- <Submit cancel ={true } {pid } {rid } on:onCancel ={onReply } on:submitComment ={submitComment } />
86+ <Submit cancel ={true } {pid } {rid } { wordLimit } on:onCancel ={onReply } on:submitComment ={submitComment } />
8187 {/if }
8288 {#if comment .replys }
8389 <div class =" D-comments-child" >
8995 child: on:onReply -> comment.svelte -> comments.svelte
9096 -->
9197 <!-- 简而言之: 此处的 on:onReply 与上方<script>里面的 onReply 方法没有半毛钱关系(仅和回复按钮的 on:click=onReply 有关系) -->
92- <svelte:self comments ={comment .replys } {replying } on:onReply on:submitComment ={submitComment } />
98+ <svelte:self comments ={comment .replys } {replying } { wordLimit } on:onReply on:submitComment ={submitComment } />
9399 </div >
94100 {/if }
95101 </div >
Original file line number Diff line number Diff line change 2020 pageCount = 1 ,
2121 showMore = false ,
2222 loading = false ,
23- replying = ' '
23+ replying = ' ' ,
24+ wordLimit
2425
2526 // 相当于vue中的watch
2627 $: {
4748 pageCount = data .pageCount
4849 comments = [... comments, ... data .comments ]
4950
51+ wordLimit = data .wordNumber
52+
5053 dispatch (' onComment' , comments .length )
5154 dispatch (' wordLimit' , data .wordNumber )
5255 } catch (error) {
9194 {/if }
9295 </div >
9396 <div class =" D-comments-list" >
94- <Comment {comments } {replying } on:onReply ={({ detail }) => (replying = detail )} on:submitComment ={submitComment } />
97+ <Comment
98+ {comments }
99+ {replying }
100+ {wordLimit }
101+ on:onReply ={({ detail }) => (replying = detail )}
102+ on:submitComment ={submitComment }
103+ />
95104 </div >
96105 {#if showMore }
97106 <div class =" D-more" >
You can’t perform that action at this time.
0 commit comments