@@ -16,17 +16,18 @@ async.
16
16
17
17
</docs >
18
18
<template >
19
- <a-mentions v-model:value =" value" :loading =" loading" @search =" onSearch" >
20
- <a-mentions-option v-for =" { login, avatar_url: avatar } in users " :key = " login " :value = " login " >
21
- <img :src =" avatar " :alt =" login" style = " width : 20 px ; margin-right : 8 px " />
22
- <span >{{ login }}</span >
23
- </a-mentions-option >
19
+ <a-mentions v-model:value =" value" :options = " options " : loading =" loading" @search =" onSearch" >
20
+ <template # option =" { payload } " >
21
+ <img :src =" payload.avatar_url " :alt =" payload. login" />
22
+ <span >{{ payload. login }}</span >
23
+ </template >
24
24
</a-mentions >
25
25
</template >
26
26
27
27
<script lang="ts">
28
28
import { debounce } from ' lodash-es' ;
29
- import { defineComponent , ref } from ' vue' ;
29
+ import { computed , defineComponent , ref } from ' vue' ;
30
+ import { MentionsProps } from ' ..' ;
30
31
export default defineComponent ({
31
32
setup() {
32
33
const value = ref <string >(' ' );
@@ -56,14 +57,29 @@ export default defineComponent({
56
57
console .log (' Search:' , searchValue );
57
58
loadGithubUsers (searchValue );
58
59
};
59
-
60
+ const options = computed <MentionsProps [' options' ]>(() =>
61
+ users .value .map (user => ({
62
+ key: user .login ,
63
+ value: user .login ,
64
+ class: ' antd-demo-dynamic-option' ,
65
+ payload: user ,
66
+ })),
67
+ );
60
68
return {
61
69
value ,
62
70
loading ,
63
71
users ,
64
72
loadGithubUsers ,
65
73
onSearch ,
74
+ options ,
66
75
};
67
76
},
68
77
});
69
78
</script >
79
+ <style >
80
+ .antd-demo-dynamic-option img {
81
+ width : 20px ;
82
+ height : 20px ;
83
+ margin-right : 8px ;
84
+ }
85
+ </style >
0 commit comments