前言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实现打字机效果
基础教程推荐
猜你喜欢
- 关于Ajax跨域问题及解决方案详析 2023-02-23
- HTML clearfix清除浮动讲解 2022-11-20
- Javascript Bootstrap的网格系统,导航栏和轮播详解 2023-08-11
- cocos creator游戏实现loading加载页面,游戏启动加载动画 2022-10-29
- 使用ajax跨域调用springboot框架的api传输文件 2023-02-23
- 在实战中可能碰到的几种ajax请求方法详解 2023-02-01
- uniapp开发微信小程序自定义顶部导航栏功能实例 2022-10-21
- JS滚动到顶部踩坑解决记录 2023-07-10
- Ajax+smarty技术实现无刷新分页 2022-12-15
- Ajax发送和接收请求 2022-12-15