vibrate.vue
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<button class="uni-button" type="primary" @click="longshock">长震动</button>
<button class="uni-button" @click="shortshock">短震动</button>
<view class="uni-tips">
<view>Tips</view>
<view class="uni-tips-text">iOS上只有长震动,没有短震动</view>
<view class="uni-tips-text">iOS上需要手机设置“打开响铃时震动”或“静音时震动”,否则无法震动</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'vibrateLong/vibrateShort'
};
},
onLoad() {},
methods: {
longshock() {
uni.vibrateLong({
success: function() {
console.log('success');
}
});
},
shortshock() {
uni.vibrateShort({
success: function() {
console.log('success');
}
});
}
}
};
</script>
<style>
.uni-padding-wrap {
margin-top: 50rpx 0;
}
.uni-button {
margin: 30rpx 0;
}
.uni-tips {
color: #666;
font-size: 30rpx;
}
.uni-tips-text {
margin-top: 15rpx;
line-height: 1.2;
font-size: 24rpx;
}
</style>