Skip to content

Instantly share code, notes, and snippets.

View Houserqu's full-sized avatar
🏠
Working from home

Houser Houserqu

🏠
Working from home
View GitHub Profile
@Houserqu
Houserqu / action.js
Last active April 2, 2018 14:50
React
import 'whatwg-fetch';
import {openSnackbar} from '../../public/action/globalAction';
export function setAttractions(attractions){
return {
type:'SET_ATTRACTIONS',
attractions:attractions
}
}
@Houserqu
Houserqu / react-router.jsx
Last active July 26, 2017 03:03
react-router常用代码
//获取当前路由
let path = hashHistory.getCurrentLocation().pathname;
//路由跳转
hashHistory.push('/');
//路由示例
<Router history={hashHistory}>
<Route path='/' component={Tabbar}> //每次都会加载 Tabbar
<IndexRoute component={Index} /> // '/'加载的路由
@Houserqu
Houserqu / axios.js
Last active August 3, 2021 13:56
http请求封装
import axios from 'axios'
import { MessagePlugin, DialogPlugin } from '@tencent/tdesign-vue' // 换成需要的提示工具库
const instance = axios.create({
timeout: 1000,
})
instance.interceptors.request.use(config => config)
instance.interceptors.response.use(response => {
@Houserqu
Houserqu / webpack.conifg.js
Created August 29, 2017 02:48
a webpack conifg with react,es6,reload,sass
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');
//定义了一些文件夹的路径
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
var TEM_PATH = path.resolve(APP_PATH, 'index.html');
module.exports = {
@Houserqu
Houserqu / json-query.js
Created December 7, 2017 12:31
json to url query
url = Object.keys(data).map(function(k) {
return encodeURIComponent(k) + '=' + encodeURIComponent(data[k])
}).join('&')
@Houserqu
Houserqu / qrcode.js
Created February 22, 2019 06:24
二维码生成组件-vue
// <script src="./resources/js/qrcode.min.js"></script>
// https://davidshimjs.github.io/qrcodejs/
Vue.component('qrcode', {
props: ['value', 'id'],
template: '<div id="id"></div>',
mounted: function () {
this.initQR()
},
methods: {
<div class="loading">
<div class="sk-fading-circle">
<div class="sk-circle1 sk-circle"></div>
<div class="sk-circle2 sk-circle"></div>
<div class="sk-circle3 sk-circle"></div>
<div class="sk-circle4 sk-circle"></div>
<div class="sk-circle5 sk-circle"></div>
<div class="sk-circle6 sk-circle"></div>
<div class="sk-circle7 sk-circle"></div>
<div class="sk-circle8 sk-circle"></div>
@Houserqu
Houserqu / webpack.config.js
Created April 3, 2019 11:40
jyjy-开发 webpack 配置
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');
//定义了一些文件夹的路径
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
var TEM_PATH = path.resolve(APP_PATH, 'index.html');
module.exports = {
@Houserqu
Houserqu / index.js
Last active March 24, 2022 08:59
金币格式化
/**
* 格式化价格
* 2000099 => 20,000.99 元
* @param num 单位分
* @param currencyType
* @returns {string}
*/
module.exports = (num, currencyType = null) => {
let value = Number(num).toFixed(2)
let parts = value.toString().split(".")
let rows = [{}]
let wb = XLSX.utils.book_new()
let ws = XLSX.utils.aoa_to_sheet(rows)
// 设置每一列宽度
ws['!cols'] = [{wpx: 120}, {wpx: 100}, {wpx: 200}, {wpx: 100}]
let name = 'excel 文件'
XLSX.utils.book_append_sheet(wb, ws, name)