Skip to content

Instantly share code, notes, and snippets.

View Alfxjx's full-sized avatar
🐶

Xu Jianxiang Alfxjx

🐶
View GitHub Profile
// 190-210元 发票计算
((count)=>{
let arr = [];
for(let i=0;i<count;i++){
arr.push(
Number((Math.random()*20).toFixed(0))+190,
);
}
console.log(arr);
let sum = arr.reduce((acc,curr)=>{return acc+curr},0)
@Alfxjx
Alfxjx / gist:6135832e3d8c0de4fb20a91cad5d5b54
Created February 24, 2021 09:01
Vue mixin 检测登录之后未操作时间,超出阈值就退出。
<script>
// 需要在App.vue上面绑定一个点击事件用来刷新时间
import { logout } from "@/api/index";
export default {
data() {
return {
nowtime: null,
timeend: null,
interval: null
};
@Alfxjx
Alfxjx / gist:65a0fd9b3227f0af0ee5788a6b15903b
Created February 23, 2021 05:38
Axios download file in blob type
export const findFile = url => {
return axiosBase.get(`path/toUrl?url=${url}`, {
responseType: "blob"
});
};
findFile(url, name) {
findFile(url).then(res => {
const resUrl = window.URL.createObjectURL(new Blob([res.data]));
const link = document.createElement("a");
const roll = () => {
return (Math.random()*10).toFixed(0) % 2 === 0?"go":"stop";
}
console.log(roll());