网站优化
网站代码优化
1.从控制台找到帮助
2.npm install babel-plugin-import –save-dev
- .babelrc 不要style
找到设置
{ "plugins": [[ "import", { "libraryName": "antd", //"style": true, // or 'css' } ]] }
4.webpack.config.js 让react减小
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
5.js压缩 开启插件 npm install compression –save compression
const compression = require('compression')
app.use(compression());
6.服务器上gzip
提交表单
fetch('url',{
headers:{
contentType:'application/json'
}
credentials:'same-origin',
body:json.stringify(data)
})
利用ref的到input的dom对象 this.props.children可实现锲套组件