1.在componentDidMount()中加入监听器
componentDidMount() {
this.screenChange();
}
screenChange() {
window.addEventListener('resize', this.resize);
}
resize()方法中,定义了屏幕尺寸变化后需要执行的代码
2.在constructor中绑定resize()
constructor(props) {
this.r...阅读全文>>
package.json:
加入
"homepage":".",
npm run eject 之后在config里面path.js 37行 路径改为相对路径,如下
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '.');阅读全文>>
Node.js发送请求
Node.js发送请求,需要用到request这个模块
request官网
先导入这个模块
npm install request --save
GET请求
var url = 'http://192.168.0.102:3000/home?name=xmg' // 发送Get请求 // 第一个参数:请求的完整URL,包括参数 // 第二个参数:请求结果回调函数,会传入3个参数,第一个错误,第二个响应对象,第三个请求数据 request(url,funct...阅读全文>>
1. cookie的创建
express直接提供了api,只需要在需要使用的地方调用如下api即可
function(req, res, next){
...
res.cookie(name, value [, options]);
...
}
express就会将其填入Response Header中的Set-Cookie,达到在浏览器中设置cookie的作用。
name: 类型为String
value: 类型为String和Obj...阅读全文>>
timedatectl set-timezone Asia/Shanghai阅读全文>>
首先安装echarts,echarts-for-react
如下:
map.js:
import React, { Component } from 'react';
import EchartsReact from "echarts-for-react"
import "echarts/map/js/china"
class ChinaMap extends Component{
// eslint-disable-next-line no-useless-constructor
constructor(props,con...阅读全文>>
import React, { Component } from 'react'
export default function asyncComponent(importComponent) {
class AsyncComponent extends Component {
constructor(props) {
super(props)
this.state = {
component: null
}
}
...阅读全文>>
rem.js:
(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
i...阅读全文>>
myChart1.getZr().on('click',function (params){
var pointInPixel= [params.offsetX, params.offsetY];
if (myChart1.containPixel('grid',pointInPixel)) {
var xIndex=myChart1.convertFromPixel({seriesIndex:0},[params.offsetX, params.offsetY])[0];
var ds = option.series[0...阅读全文>>
WebSocket是tcp/ip协议之上的一个Socket协议,是为了解决服务器向浏览器主动推送的场景而生,关于该协议的其它内容,本文不做赘述。今天主要讲述一下使用express-ws在NodeJs中如何实现WebSocket 通讯。
必备知识:
NodeJs 基础
Express 框架
H5 WebSocket API
如果不清楚以上内容的请点击以上链接查看相关文档。
基本使用:
要想使用express-ws,首先要安装express以及express-ws:
np...阅读全文>>