当前位置: 首页 > news >正文

asp.net做电商网站页面重庆企业站seo

asp.net做电商网站页面,重庆企业站seo,郴州市旅游景点排行榜,h5和网页有什么区别在现代前端开发中,添加一些视觉效果可以提升用户体验。其中,打字机效果是一种常见且吸引人的效果,可以用于展示动态文本。本文将介绍如何在 Vue 3 中实现打字机效果。 实现步骤 1. 创建自定义指令 我们首先创建一个自定义指令 v-typewriter…

在现代前端开发中,添加一些视觉效果可以提升用户体验。其中,打字机效果是一种常见且吸引人的效果,可以用于展示动态文本。本文将介绍如何在 Vue 3 中实现打字机效果。

实现步骤

1. 创建自定义指令

我们首先创建一个自定义指令 v-typewriter,用于实现打字机效果。这个指令将逐字显示绑定的文本内容。

const typeWriter = ref(null);const typewriterDirective = (el, binding) => {const indexValue = el.getAttribute('data-index');const delay = 150; // 设置延迟时间,默认150mslet i = 0;typeWriter.value = setInterval(() => {if (binding?.value && i < binding.value.length) {if (textList.value && textList.value[indexValue]) {textList.value[indexValue].typewriterText += binding.value.charAt(i) || '';}i++;} else {clearInterval(typeWriter.value);stop(textList.value[indexValue], indexValue, true);}}, delay);
};const vTypewriter = {mounted(el, binding) {typewriterDirective(el, binding);}
};

2. 使用自定义指令

在 Vue 组件中使用自定义指令 v-typewriter。该指令会在元素挂载时自动触发,逐字显示文本内容。

<template><div class="left-content mr-16"><el-scrollbar ref="scrollRef" height="100%" class="scroll"><div class="flex mb-48" v-for="(item, index) in textList" :key="item.updateKey"><div class="user-avatar"><img v-if="item.resultTts || item.library" src="/img/avatar.png" alt="" /><img v-else src="/img/user_avatar.png" alt="" /></div><div class="ml-12"><div class="time mb-11"><span v-if="item.resultTts || item.library">智能馆员{{ item.time }}</span><span v-else>读者{{ item.time }}</span></div><div><divclass="answer":class="item.resultTts || item.library ? 'libarary-bg' : 'user-color '"><div v-if="item.resultTts || item.library"><van-loading v-if="!item.resultMessage" type="spinner" color="#1989fa" /><div v-if="item.isStop && item.stopText">{{ item.stopText }}</div><divv-if="item.resultTts && !item.isStop"v-typewriter="item.resultTts":data-index="index">{{ item.typewriterText }}</div></div><div v-else>{{ item.resultMessage }}</div></div><divv-if="(!item.isStop && item.resultTts) || !item.resultMessage"class="stop-icon mt-18"@click="stop(item, index)">停止生成</div></div><BookListv-if="item.dataList?.length && item.isStop":data-list="item.dataList"></BookList></div></div></el-scrollbar></div>
</template><script>
import { ref } from 'vue';
import { useEventBus } from '@/hooks/useEventBus';const emits = defineEmits(['watchTypeWriter', 'handleStop']);const textList = ref([]);
useEventBus('clearChatInfo', () => {textList.value = [];
});
useEventBus('changeAction', (message) => {
// message其它组件传递的数据 clearInterval(typeWriter.value);if (!textList.value.length || !message.resultTts) {textList.value.push({time: ` ${dayjs().format('HH:mm:ss')}`,isStop: false,  // 是否停止stopText: '',   // 打字机停止后的内容typewriterText: '',  // 动态展示打字机内容的文本updateKey: dayjs().valueOf(), // 每次增加一条数据的唯一key...message});return;}if (textList.value.length && message.resultTts) {textList.value[textList.value.length - 1] = {...textList.value[textList.value.length - 1],...message};}
});const stop = (item, index, isFinish = false) => {if (!item.resultMessage) {item.isStop = true;emits('handleStop');return;}if (item.isStop) {return;}const curText = document.querySelector(`[data-index="${index}"]`);item.isStop = true;item.stopText = curText?.innerText;
};
</script><style scoped lang="scss">
/* 自定义样式*/
</style>
http://www.15wanjia.com/news/40356.html

相关文章:

  • 龙岗建设网站关于seo的行业岗位有哪些
  • 泉州市网站建设怎么接推广
  • 保定工程建设信息网站最新军事新闻 今日 最新消息
  • 网站建设及长春seo技术
  • 晋中做网站在线客服系统
  • 企业网站案例公司惊艳的网站设计
  • 查看网站是什么语言做的西安网络seo公司
  • 一键logo生成器在线昆山优化外包
  • php网站怎么做集群网络上哪里可以做推广
  • python 做网站开发企业网络推广的方法
  • 全国知名网站建设seo的概念是什么
  • 做网站的公司哪好天津搜索引擎推广
  • wordpress批量发布工具郑州seo顾问热狗hotdoger
  • 做视频解析网站播放器和接口太原优化排名推广
  • 盐城网站建设制作方案百度云盘搜索
  • 贴吧做网站java成品网站
  • 中小型网站建设价格优化工具箱下载
  • 镜像网站怎么做排名win10优化软件
  • wordpress 科技联盟seo的搜索排名影响因素有哪些
  • 电子商务网站建设的方法及流程图营销推广软件
  • 初中信息科技怎么自己做网站网络推广站
  • 湛江北京网站建设免费推广方法
  • 网站建设全网营销百度个人中心登录
  • 网站开发投资成本搜索引擎的使用方法和技巧
  • 同一个域名两个网站手机如何做网站
  • 君隆做网站怎么样公司网络推广网站
  • 龙岗建网站公司站群seo
  • 用服务器做网站网站排名优化多少钱
  • 公司网站维护费 入什么科目百度推广和优化有什么区别
  • 网站seo推广友情链接的网站有哪些