|
22 | 22 | <li>{{ zh ? '支持在布局变化时自动更新。' : 'Automatically updates upon layout change.' }}</li>
|
23 | 23 | <li>{{ zh ? '支持展开/收起被截断部分内容。' : 'The clamped text can be expanded/collapsed.' }}</li>
|
24 | 24 | <li>{{ zh ? '支持自定义截断文本前后内容,并且进行响应式更新。' : 'Customizable and responsive content before/after clamped text.' }}</li>
|
| 25 | + <li>{{ zh ? '支持在文本末尾、中间或开始位置进行截断。' : 'Place elllipsis at the end, middle, or the start of the clamped text' }}</li> |
25 | 26 | </ul>
|
26 | 27 | <h2 id="demo">
|
27 | 28 | <a href="#demo">#</a> Demo
|
28 | 29 | </h2>
|
| 30 | + <div class="divider text-center" data-content="↓ customizable ellipsis location & max-lines"/> |
| 31 | + <section class="case"> |
| 32 | + <div class="form-horizontal"> |
| 33 | + <div v-if="!zh" class="form-group"> |
| 34 | + <label class="form-label col-5 col-sm-12" for="location">{{ zh ? '地点' : 'Location' }}</label> |
| 35 | + <div class="col-3 col-sm-12"> |
| 36 | + <label class="form-radio"> |
| 37 | + <input v-model="location" type="radio" value="start"> |
| 38 | + <i class="form-icon"/> |
| 39 | + Start |
| 40 | + </label> |
| 41 | + </div> |
| 42 | + <div class="col-3 col-sm-12"> |
| 43 | + <label class="form-radio"> |
| 44 | + <input v-model="location" type="radio" value="middle"> |
| 45 | + <i class="form-icon"/> |
| 46 | + Middle |
| 47 | + </label> |
| 48 | + </div> |
| 49 | + <div class="col-1 col-sm-12"> |
| 50 | + <label class="form-radio"> |
| 51 | + <input v-model="location" type="radio" value="end"> |
| 52 | + <i class="form-icon"/> |
| 53 | + End |
| 54 | + </label> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + <div class="form-group"> |
| 58 | + <label class="form-label col-5 col-sm-12" for="lines">{{ zh ? '最大行数' : 'Max lines' }}</label> |
| 59 | + <div class="col-7 col-sm-12"> |
| 60 | + <input |
| 61 | + id="lines" |
| 62 | + v-model.number="lines" |
| 63 | + class="form-input" |
| 64 | + type="number" |
| 65 | + min="1" |
| 66 | + max="8" |
| 67 | + step="1" |
| 68 | + > |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + <div class="form-group"> |
| 72 | + <label |
| 73 | + class="form-label col-5 col-sm-12" |
| 74 | + for="width1" |
| 75 | + >{{ zh ? '容器宽度' : 'Container width' }}</label> |
| 76 | + <div class="col-7 col-sm-12 tooltip" :data-tooltip="`${width1}px`"> |
| 77 | + <input id="width1" v-model="width1" class="slider" type="range" min="240" max="600"> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + <div v-if="!zh" class="form-group"> |
| 81 | + <div class="col-5 col-sm-12"> |
| 82 | + <label class="form-checkbox"> |
| 83 | + <input v-model="hyphens1" type="checkbox"> |
| 84 | + <i class="form-icon"/> |
| 85 | + CSS Hyphens |
| 86 | + </label> |
| 87 | + </div> |
| 88 | + <div class="col-5 col-sm-12"> |
| 89 | + <label class="form-checkbox"> |
| 90 | + <input v-model="rtl1" type="checkbox"> |
| 91 | + <i class="form-icon"/> |
| 92 | + RTL |
| 93 | + </label> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + <v-clamp |
| 98 | + :class="{ |
| 99 | + demo: true, |
| 100 | + hyphens: hyphens1, |
| 101 | + rtl: rtl1 |
| 102 | + }" |
| 103 | + :max-lines="lines" |
| 104 | + :location="location" |
| 105 | + autoresize |
| 106 | + :style="{ |
| 107 | + width: `${width1}px` |
| 108 | + }" |
| 109 | + > |
| 110 | + {{ zh ? textZh : text }} |
| 111 | + <template #after="{ toggle, expanded, clamped }"> |
| 112 | + <button |
| 113 | + v-if="expanded || clamped" |
| 114 | + class="toggle btn btn-sm" |
| 115 | + @click="toggle" |
| 116 | + >{{ zh ? '切换' : 'Toggle' }}</button> |
| 117 | + </template> |
| 118 | + </v-clamp> |
| 119 | + </section> |
29 | 120 | <div class="divider text-center" data-content="↓ max-lines & slot `after`"/>
|
30 | 121 | <section class="case">
|
31 | 122 | <div class="form-horizontal">
|
@@ -533,6 +624,7 @@ export default {
|
533 | 624 | return {
|
534 | 625 | lines: 3,
|
535 | 626 | width1: 600,
|
| 627 | + location: 'end', |
536 | 628 | hyphens1: true,
|
537 | 629 | rtl1: false,
|
538 | 630 | expanded1: false,
|
|
0 commit comments