前言github:https://github.com/pengqiangsheng/easy-typer-js内容安装npm install easy-typer-js --save封装print.jsimport EasyTyper from easy-typer-jsexport default {data() {return {windowHeight: 0...
前言
github:https://github.com/pengqiangsheng/easy-typer-js
内容
安装
npm install easy-typer-js --save
封装

print.js
import EasyTyper from 'easy-typer-js'
export default {
data() {
return {
windowHeight: 0,
obj: {
output: '',
isEnd: false,
speed: 80,
singleBack: false,
sleep: 10,
type: 'custom',
backSpeed: 40,
sentencePause: false
}
}
},
methods: {
initTyped(input) {
const obj = this.obj
const typed = new EasyTyper(obj, input)
}
},
}
index.js
import share from './src/share.js';
import printText from './src/print.js'
export { share, printText }
使用
<template>
<view class="flex color_gradient" :style="{height:windowHeight+'rpx'}" @click="userDetail">
<view class="flex justify-center align-center">
<view class="text-white text-bold text-sl text-center padding">{{ obj.output }}
<span class="typed-cursor">|</span>
</view>
</view>
</view>
</template>
<script>
import { printText } from '@/mixins/index.js'
export default {
mixins: [printText],
data() {
return {
windowHeight:0,
obj: {
output: '',
speed: 100,
}
}
},
created() {
let that = this
uni.getSystemInfo({
success(res) {
that.windowHeight = res.windowHeight*2
}
})
},
mounted() {
this.initTyped('王洋')
},
methods: {
userDetail(){
wx.navigateTo({
url: '../info/index',
})
}
}
}
</script>
效果

编程基础网
本文标题为:VUE——使用easy-typer-js实现打字机效果
基础教程推荐
猜你喜欢
- html网页中使用希腊字母的方法 2022-09-21
- vue在install时node-sass@4.14.1 postinstall:node scripts/build.js错误解决 2023-07-09
- ajax异步加载图片实例分析 2022-12-18
- AJAX实现数据的增删改查操作详解【java后台】 2023-02-23
- JavaScript函数this指向问题详解 2023-08-12
- JavaScript开发简单易懂的Svelte实现原理详解 2023-08-12
- Ajax实现关键字联想和自动补全功能及遇到坑 2023-02-23
- 【vue】三种获取input值的写法 2023-10-08
- Ajax实现简单下拉选项效果【推荐】 2022-12-28
- 使用HTML5中postMessage知识点解决Ajax中POST跨域问题 2022-10-17
