Yu Mobile Tool 移动端常用工具库
版本
引入
使用 npm 或 yarn 安装
$ npm install yu-mobile-tool --save
或者
$ yarn add yu-mobile-tool
import YuMobileTool from 'yu-mobile-tool'
import 'yu-mobile-tool/dist/style.css'
浏览器引入
<script src="~filepath/yu-mobile-tool.min.js"></script>
<link rel="stylesheet" href="~filepath/style.css">
使用
Toast 文本提示
YuMobileTool.Toast(message, duration)
参数说明
参数 |
类型 |
必填 |
默认值 |
说明 |
message |
String |
是 |
无 |
信息文本 |
duration |
Number |
否 |
1500 |
显示时长(毫秒) |
使用 npm 或 yarn
import YuMobileTool from 'yu-mobile-tool'
const spin = YuMobileTool.Toast('操作成功', 2000)
浏览器引入
<script>
YuMobileTool.Toast('操作成功', 2000)
</script>
Spin 加载效果
const spin = new YuMobileTool.Spin(target, options).show()
参数说明
参数 |
类型 |
必填 |
默认值 |
说明 |
target |
String/DOM |
是 |
无 |
目标节点 |
options |
Object |
否 |
transparent: true |
spin的配置 |
使用 npm 或 yarn
import YuMobileTool from 'yu-mobile-tool'
const spin = new YuMobileTool.Spin('#app', {
transparent: false,
show: false
})
spin.show()
spin.hide()
浏览器引入
<div class="test-box"></div>
<script>
const spin = new YuMobileTool.Spin('.test-box')
spin.show()
setTimeout(() => {
spin.hide()
}, 3000)
</script>