Gsap基本使用

Gsap基本使用

1. 下载

1
2
// power shell
npm i gsap

2.导入

1
2
//main.js
import { gsap } from "gsap";

3.编写配置文件

1
2
3
4
5
6
7
8
9
// vue.config.js
const path = require('path');

module.exports = {
chainWebpack: config => {
config.resolve.alias.set('gsap', path.resolve(__dirname, 'node_modules', 'gsap')); // 设置GSAP别名
}
};

4.使用gsap

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { gsap } from "gsap";

export const flow =()=>{
gsap.set(".flow",{
y:"-20px",
});
gsap.to(".form", {
y: '0',
duration: 1,
repeat: -1,
yoyo: true,
ease: "power1.inOut"
});
}

5.全部代码

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
<view class="main">
<view class="flow form">
<input type="text" placeholder="账号" v-model="user.acc">
<input type="text" placeholder="密码" v-model="user.pwd">
<button size="mini" type="default" @click="loginIn">登录</button>
<button size="mini" type="default" @click="reset">取消</button>
</view>
<view class="dots">
<view class="dot"></view>
<view class="dot"></view>
<view class="dot"></view>
</view>

<view class="bg-container"></view>
</view>
</template>

<script>
import {
flow,
showMessage
} from '../../gsap/index.js'
import {
$login
} from '../../api/index.js'
export default {
data() {
return {
user: {
acc: '',
pwd: '',
}
}
},
mounted() {
flow();
},
methods: {
async loginIn() {
if (this.user.acc.length <= 0 || this.user.pwd.length <= 0) {
showMessage('请输入账号或密码...');
return;
}
let data = await $login(this.user);
if (data.length >= 1) {
uni.setStorage({
key: 'account',
data: this.user.acc,
success: (res) => {
console.log('记录登录+1');
}
})
uni.navigateTo({
url: '/pages/index/index',
animationType: 'slide-in-right'
})
} else {
showMessage('账号或密码错误...');
}
},
reset() {
this.user.acc = '';
this.user.pwd = '';
}
},
onLoad() {
uni.getStorage({
key: 'account',
success: (res) => {
if (res.data.length >= 0) {
uni.navigateTo({
url: '/pages/index/index',
animationType: 'slide-in-right'
})
}
}
})
},
}
</script>

<style scoped>
* {
--hei: 40px;
}

.main {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}

.form {
width: 70%;
height: 300px;
border-radius: 10px;
border: 4px solid orange;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 30px;
box-shadow: 0px 3px 10px 2px #fff;
}

button {
color: white;
width: 100%;
height: var(--hei);
line-height: var(--hei);
margin: 10px 0;
background-color: orange;
border: none;
}

button:active {
color: white;
background-color: rgba(255, 165, 0, .4);
}

input {
width: 100%;
font-size: 14px;
height: var(--hei);
margin: 10px 0;
border: 2px solid orange;
padding: 0 10px;
border-radius: 6px;
}

.dots {
width: 40%;
height: 20px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}

.dot {
width: 20px;
height: 20px;
background-color: orange;
border-radius: 50%;
}
</style>

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2022-2024 何福海
  • 访问人数: | 浏览次数:

请我喝杯奶茶吧~

支付宝
微信