在说"基于现场数据'页面缓慢'"时,使用90百分位而不是中位数分数,使得大量被贩运的网站(例如google.com)无法获得"快速"排名吗?这是由于每月流量在10M +范围内时会出现长尾?
上次我检查(2018年2月初),桌面google.com获得了100个灯塔合成分数,应该被解释为"几乎没有改进的余地",然而,该页面排名"慢",因为第90百分位FCP超过3秒.
使用此标准时,像nytimes.com这样的页面是否会被认为很快,甚至google.com的桌面页面根据现场数据排名很慢?
performance performance-testing lighthouse chrome-ux-report pagespeed-insights
我想从我的 .env 文件中获取我的变量,但我总是得到 undefined
这是我的 js 代码:
require('dotenv').config();
class Header extends React.Component{
constructor(props){...}
render(){
console.log("NODE ENV", process.env.NODE_ENV);
console.log("REACT_APP_MYAPP", process.env.REACT_APP_MYAPP);
...
}
}
Run Code Online (Sandbox Code Playgroud)
这打印:
NODE_ENV 开发
REACT_APP_MYAPP
undefined
在我的 package.json 中有:
"scripts":{
"start" : "webpack-dev-server --config webpack.dev.js",
"build" : "webpack --config webpack.prod.js"
}
Run Code Online (Sandbox Code Playgroud)
在我的 webpack.dev.js 中:
const webpack = require("webpack");
const merge = require("webpack-merge");
const path = require("path");
const common = require("./webpack.common.js");
module.exports = merge.smart(common, {
devServer: {
contentBase: path.resolve(__dirname, "dist"),
hot: true,
overlay: {
warnings: true,
errors: true
},
inline …Run Code Online (Sandbox Code Playgroud) 我有一个做认证的中间件。在此身份验证方法中,我需要设置一个响应标头。
server.get('/api/users, auth(), getUsers);
Run Code Online (Sandbox Code Playgroud)
我的身份验证方法:
module.exports = (isProduction) => {
return function(req, res, next){
...
next();
}
}
Run Code Online (Sandbox Code Playgroud)
如何在此auth函数中附加标题?
谨防!这个问题可能令人困惑并且无关紧要,因为我对错误原因的假设是错误的,问题出在减速器上,而不是我代表数据的方式。
因此,问题的正确答案是jpdelatorre的答案,而 Joao的答案是关于错误本身的。
假设我有来自服务器的JSON响应,它是一组嵌套对象。如何弄平它以使商店处理尽可能容易?我试图使用这样的normalizr工具:
const imageSchema = new Schema('image', { idAttribute: 'id' });
const tooltipSchema = new Schema('tooltips', { idAttribute: 'id' });
imageSchema.define({
tooltips: arrayOf(tooltipSchema),
});
const initData = data.map(item => normalize(item, imageSchema));
Run Code Online (Sandbox Code Playgroud)
但是我相信我做错了,因为它没有太大帮助。存储仍然太复杂,因此我需要在reducer中使用一些递归的东西来更新状态。
此外,深层嵌套的状态也使得使用react-redux变得connect()非常困难,因为它仅进行了比较浅的比较。
响应的形状如下:
[
{
"id": 1,
"title": "Partridge",
"tooltips": [
{
"id": 10,
"x": 0.56,
"y": 0.59,
"content": "Jacky"
},
{
"id": 11,
"x": 0.08,
"y": 0.8,
"content": "Sarah"
}
]
},
{
"id": 2,
"title": "The Great Seal …Run Code Online (Sandbox Code Playgroud) reactjs ×2
express ×1
lighthouse ×1
node.js ×1
normalizr ×1
performance ×1
redux ×1
webpack ×1