@antdigital/card-text
Advanced tools
+173
| <template> | ||
| <template> | ||
| <text | ||
| v-if="clickable" | ||
| :class="`text ${className}`" | ||
| :style="realStyle" | ||
| :value="myText" | ||
| :name="name" | ||
| @click="onClick()" | ||
| :addManualSpm="addManualSpm" | ||
| :spmBizCode="spmBizCode" | ||
| :scm="scm" | ||
| :spm="spm" | ||
| :entityId="entityId" | ||
| :extraParams4="extraParams4" | ||
| /> | ||
| <text | ||
| v-else | ||
| :class="`text ${className}`" | ||
| :style="realStyle" | ||
| :value="myText" | ||
| :name="name" | ||
| :addManualSpm="addManualSpm" | ||
| :spmBizCode="spmBizCode" | ||
| :scm="scm" | ||
| :spm="spm" | ||
| :entityId="entityId" | ||
| :extraParams4="extraParams4" | ||
| /> | ||
| </template> | ||
| </template> | ||
| <script> | ||
| var main = { | ||
| props: { | ||
| className: { | ||
| default: "" | ||
| }, | ||
| style: { | ||
| default: {} | ||
| }, | ||
| value: { | ||
| default: "" | ||
| }, | ||
| // 'word'|'letter' 换行截断方式,单词/文字 | ||
| breakType: { | ||
| default: "word" | ||
| }, | ||
| // 打印时间间隔 | ||
| timeInterval: { | ||
| default: null | ||
| }, | ||
| // 间隔增加几个字母 | ||
| speed: { | ||
| default: 1 | ||
| }, | ||
| lines: { | ||
| default: null | ||
| }, | ||
| width: { | ||
| default: null | ||
| }, | ||
| clickable: { | ||
| default: true | ||
| }, | ||
| params: { | ||
| default: null | ||
| }, | ||
| // 埋点 | ||
| addManualSpm: { | ||
| default: false | ||
| }, | ||
| spmBizCode: { | ||
| default: "HomeAssistant" | ||
| }, | ||
| name: { | ||
| default: "exposure" | ||
| }, | ||
| spm: { | ||
| default: null | ||
| }, | ||
| scm: { | ||
| default: null | ||
| }, | ||
| entityId: { | ||
| default: null | ||
| }, | ||
| extraParams4: { | ||
| default: null | ||
| } | ||
| }, | ||
| data: { | ||
| timer: null, | ||
| // 计时器 | ||
| progress: 0 // 当前文本书写进度 | ||
| }, | ||
| onCreated() { | ||
| this.useParams(); | ||
| this.startPrint(); | ||
| }, | ||
| onUpdated(key) { | ||
| this.useParams(); | ||
| if (key === "value") { | ||
| this.progress = 0; | ||
| } | ||
| this.startPrint(); | ||
| }, | ||
| computed: { | ||
| myText() { | ||
| if (this.timeInterval) { | ||
| return this.value.substring(0, this.progress); | ||
| } | ||
| return this.value; | ||
| }, | ||
| realStyle() { | ||
| return { | ||
| whiteSpace: this.lines === 1 ? "nowrap" : this.style.whiteSpace, | ||
| ...this.style, | ||
| lines: this.lines || this.style.lines, | ||
| width: this.width || this.style.width, | ||
| wordBreak: this.breakType === "word" ? null : "break-all" | ||
| }; | ||
| } | ||
| }, | ||
| methods: { | ||
| // 开始打印 | ||
| startPrint() { | ||
| if (!this.timeInterval) { | ||
| return; | ||
| } | ||
| // speed必须为整数 | ||
| this.speed <= 1 ? 1 : Math.round(this.speed); | ||
| this.$emit("startPrint"); | ||
| if (this.value.trim().length === 0) { | ||
| return; | ||
| } | ||
| this.timer = setInterval(() => { | ||
| if (this.progress < this.value.length) { | ||
| this.progress = Math.min(this.value.length, this.progress + this.speed); | ||
| } else { | ||
| this.$emit("play-finished"); | ||
| clearInterval(this.timer); | ||
| } | ||
| }, this.timeInterval); | ||
| }, | ||
| useParams() { | ||
| if (this.params) { | ||
| for (let key in this.params) { | ||
| this[key] = this.params[key]; | ||
| } | ||
| } | ||
| }, | ||
| // 点击文字 | ||
| onClick() { | ||
| this.$emit("click"); | ||
| } | ||
| }, | ||
| onDestroyed() { | ||
| // 清除计时器 | ||
| clearInterval(this.timer); | ||
| } | ||
| }; | ||
| export { main as default }; | ||
| </script> | ||
| <style> | ||
| .text { | ||
| font-size: 30rpx; | ||
| text-overflow: ellipsis; | ||
| overflow: hidden; | ||
| color: #1f3b63; | ||
| } | ||
| </style> |
| { | ||
| "name": "@antdigital/card-text", | ||
| "compilerType": 1, | ||
| "jsformat": 1, | ||
| "isComponent": true, | ||
| "assetId": "180020010101324445", | ||
| "useComponents": {} | ||
| } |
+4
-2
| { | ||
| "name": "@antdigital/card-text", | ||
| "version": "9.0.1", | ||
| "version": "9.0.4", | ||
| "yuyanId": "180020010101324445", | ||
@@ -19,3 +19,5 @@ "repository": { | ||
| "config.schema", | ||
| "esm" | ||
| "esm", | ||
| "main.vue", | ||
| "manifest.json" | ||
| ], | ||
@@ -22,0 +24,0 @@ "keywords": [ |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
8162
75.72%6
50%16
100%0
-100%