赞
踩
20230722_111203
npm install --save vue-typed-js
安装组件期间遇到的问题以及解决方案:
以下是运行命令后的第一个报错信息:
PS G:\vx-pc\blog-friend> npm install --save vue-typed-js
npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @vue/eslint-config-standard@6.1.0
npm WARN Found: eslint-plugin-vue@8.7.1
npm WARN node_modules/eslint-plugin-vue
npm WARN dev eslint-plugin-vue@"^8.0.3" from the root project
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0
npm WARN node_modules/@vue/eslint-config-standard
npm WARN dev @vue/eslint-config-standard@"^6.1.0" from the root project
npm WARN
npm WARN Conflicting peer dependency: eslint-plugin-vue@7.20.0
npm WARN node_modules/eslint-plugin-vue
npm WARN peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0
npm WARN node_modules/@vue/eslint-config-standard
npm WARN dev @vue/eslint-config-standard@"^6.1.0" from the root project
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
错误消息指示可能存在依赖项的冲突。
打开项目中的
package.json
文件,在dependencies
或devDependencies
部分查找eslint-plugin-vue版本是否为7.20.0版本。如果不是请在终端中运行以下命令来更新依赖项的版本。完成后重新运行该命令:npm install --save vue-typed-jsnpm install eslint-plugin-vue@7.20.0
如果你遇到的是以下报错信息:
G:\vx-pc\blog-friend> npm install --save vue-typed-js
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent这个错误通常是由于npm无法找到git的路径而引起的。这可能是因为你的计算机上没有正确设置或安装git,或者git的执行路径没有正确配置。
如果您已经正确安装了git,但npm仍然无法找到它,请确保git的可执行文件路径已正确配置到系统的PATH环境变量中。尝试重启计算机以确保新的环境变量生效。
如果你没有安装git,你可以从git的官方网站(https://git-scm.com/downloads)下载并安装最新版本的git。
配置Git后依然报同样的错误信息请使用以下办法100%解决:
桌面右键菜单项选择git bash here打开窗口运行以下几条命令:
npm init -y npm i npm install vue-typed-js
- import Vue from 'vue'
- import VueTypedJs from 'vue-typed-js'
-
- Vue.use(VueTypedJs)
- <template>
- <div>
- <vue-typed-js
- class="desc"
- :strings="typingTexts"
- :loop="true"
- :startDelay="300"
- :typeSpeed="100"
- :backSpeed="50"
- :showCursor="false"
- >
- <span class="typing"></span>
- </vue-typed-js>
- </div>
- </template>
-
- <script>
- export default {
- data() {
- return {
- typingTexts: [
- "我可以成为任何人,但任何人不是我",
- "我只想做自己",
- ],
- };
- }
- };
- </script>
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
字符串 | 数组 | 要键入的字符串 | :strings="['Text 1', 'Text 2']" |
字符串元素 | 字符串 | 包含字符串子元素的 ID | :stringsElement="'myId'" |
类型速度 | 数 | 键入速度(以毫秒为单位) | :typeSpeed="50" |
开始延迟 | 数 | 键入开始之前的时间(以毫秒为单位) | :startDelay="1000" |
回速 | 数 | 后间距速度(毫秒) | :backSpeed="10" |
智能退格 | 布尔 | 仅退格键与上一个字符串不匹配的内容 | :smartBackspace="true" |
洗牌 | 布尔 | 随机播放字符串 | :shuffle="true" |
返回延迟 | 数 | 后退间距之前的时间(以毫秒为单位) | :backDelay="100" |
淡出 | 布尔 | 淡出而不是退格 | :fadeOut="true" |
淡出类 | 字符串 | 用于淡入淡出动画的 CSS 类 | :fadeOutClass="'fadeOutClass'" |
淡出延迟 | 数 | 淡出延迟(以毫秒为单位) | :fadeOutDelay="500" |
圈 | 布尔 | 循环字符串 | :loop="true" |
循环计数 | 数 | 循环数 | :loopCount="3" |
显示光标 | 布尔 | 显示光标 | :showCursor="true" |
光标字符 | 字符串 | 光标的字符 | :cursorChar="'_'" |
autoInsertCss | 布尔 | 插入光标的 CSS 并淡出到 HTML 中 | :autoInsertCss="true" |
吸引力 | 字符串 | 用于键入 Ex 的属性:输入占位符、值或仅输入 HTML 文本 | :attr="'placeholder'" |
绑定输入焦点事件 | 布尔 | 绑定到焦点和模糊(如果 el 是文本输入) | :bindInputFocusEvents="true" |
内容类型 | 字符串 | “html”或“null”表示纯文本 | :contentType="'html'" |
您可以收听以下事件:
事件 | 描述 | 用法 |
---|---|---|
在完成 | 所有键入都已完成 | @onComplete="doSmth()" |
preStringTyped | 键入每个字符串之前 | @preStringTyped="doSmth()" |
onStringTyped | 键入每个字符串后 | @onStringTyped="doSmth()" |
onLastStringBackspaced | 在循环期间,键入最后一个字符串之后 | @onLastStringBackspaced="doSmth()" |
onTyping暂停 | 键入已停止 | @onTypingPaused="doSmth()" |
onTyping已恢复 | 停止键入后已开始键入 | @onTypingResumed="doSmth()" |
复位时 | 复位后 | @onReset="doSmth()" |
停止 | 停止后 | @onStop="doSmth()" |
在开始 | 启动后 | @onStart="doSmth()" |
销毁 | 销毁后 | @onDestroy="doSmth()" |
最后附一下 vue-typed-js
这个插件的地址:GitHub - Orlandster/vue-typed-js: Typed.js integration for vue.js. Create a typing animation.
总得来说,挺好用的。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。