Foreword:
Cookies are used in the project, js-cookie is very common, but our expiration time, he supports days by default, if we want to change to hours, what should we do, here is how to share
The official entrance of js-cookie
Implementation:
import Cookies form 'js-cookie'
let num = 2 //失效时间是几小时
let time= new Date(new Date().getTime() + num * 60 * 60 * 1000);
Cookies.set(self.loginForm.account, res.data.data, {
expires: time
});