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
| <template>
| <view v-if="visible" class="custom-toast">
| <view class="toast-content">
| <text>{{ message }}</text>
| </view>
| </view>
| </template>
|
| <script>
| export default {
| data() {
| return {
| visible: false,
| message: ''
| };
| },
| methods: {
| showToast(message) {
| this.message = message;
| this.visible = true;
| setTimeout(() => {
| this.visible = false;
| }, 2000); // 2秒后自动隐藏
| }
| }
| };
| </script>
|
| <style>
| .custom-toast {
| position: fixed;
| bottom: 20%;
| left: 50%;
| transform: translateX(-50%);
| background-color: red; /* 背景颜色设置为红色 */
| padding: 20px;
| border-radius: 10px;
| z-index: 9999;
| }
|
| .toast-content {
| color: white; /* 字体颜色设置为白色 */
| font-size: 16px;
| text-align: center;
| }
| </style>
|
|