vue2 el-input里实现打字机 效果

vue2 el-input里实现打字机 效果

<el-col :span="24" v-if="ifshowOtherDesc"">
                    <el-form-item label="分析" prop="otherDesc">
                        <el-input type="textarea" :disabled="disabled" autofocus="true" v-model="ruleForm.otherDesc" maxlength="3000" :rows="4" show-word-limit />
                    </el-form-item>
                </el-col>
<el-col :span="24" v-if="&& !ifshowOtherDesc">
                    <el-form-item label="分析">
                            <div class="modelAnalysisInput">
                                <vue-typed-js
                                class="desc"
                                :typeSpeed="10"
                                v-if="isTypingOtherDesc"
                                @onComplete="doDelayOtherDesc"
                                :strings="typingTextsOtherDesc"
                                :showCursor="false"
                                >
                                <div class="typing" style="white-space: pre-wrap;line-height: 1.5;color:#666"></div>
                                </vue-typed-js>
                            </div>
                    </el-form-item>
                </el-col>
script
data
isTypingOtherDesc: false,
            ifshowOtherDesc:true,
            typingTextsOtherDesc: [],
method
doDelayOtherDesc() {
            let that = this;
            setTimeout(()=>{
                this.ruleForm.otherDesc = this.typingTextsOtherDesc.toString();
                 that.isTypingOtherDesc = false;
                 that.ifshowOtherDesc = true;
            },300)
                
        },

通过假打字 @onComplete=“doDelayOtherDesc” 监听结束时赋值,关闭打字机的div 显示el-input,实现无缝切换的 gpt打字效果。

1.typingTextsOtherDesc=[‘111111’,‘22222’]
打字机需要的字符格式是数组里有字符串的格式。赋值给input需要toString() 转字符串。不然maxlength=“3000” :rows=“4” show-word-limit
的input data赋值会显示1/3000而非实际字数。
2.换行 需要后端在字符里+ \n换行

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值