最近在用create-react-app 脚手架自己写一个小项目,遇到了很多坑,其中有一个就是React 引用本地图片的问题,我的需求是,图片的路径写在json文件里,需要从后台读取json文件,然后读取到图片的路径,在前端渲染。那么问题来了,es6不支持在<img />标签内直接写图片的路径,即:
<img src="../images/photo.png"/>
这种格式是不支持的。在网上看了很多博客,总结下以下几个加载的方法,当然,这种是在图片不多的情况下可以采用。
(1)import 方法:
import imgURL from './...阅读全文>>
/*
* 2、闭包的封装方式,在这个封装方法中,所有的实例成员都共享属性和方法
* 使得所有得方法和属性都私有且对象间共享
* */
var Person=(function(){
/*共享函数*/
let checkNo=function(no){
if(!no.constr...阅读全文>>
安装webpack-bundle-analyzer
Webpack.config.js引入
let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
配置plugin:
plugins: [new BundleAnalyzerPlugin({
// 可以是`server`,`static`或`disabled`。
&n...阅读全文>>
import axios from 'axios'
import { Message, MessageBox } from 'element-ui'
import store from '../store'
import { getToken } from '@/utils/auth'
// 创建axios实例
const service = axios.create({
baseURL: process.env.BASE_API, // api的base_url
timeout: 5000 ...阅读全文>>
# timedatectl list-timezones # 列出所有时区
# timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
# timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海
其实不考虑各个发行版的差异化, 从更底层出发的话, 修改时间时区比想象中要简单:
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime阅读全文>>
const nodemailer = require("nodemailer"); //发送邮件的node插件
const smtpTransport = require('nodemailer-smtp-transport');
function sendMail(HtmlData) {
const template = ejs.compile(
fs.readFileSync(path.resolve(__dirname, "email.ejs"), "utf8")
...阅读全文>>
https://juejin.im/post/5c85a64d6fb9a04a0e2e038c?utm_source=gold_browser_extension
proxy_pass 后跟的服务器URL值是否以 / 结尾的区别:
若 Nginx 收到请求为 https://ngxin_server_name/hello/world
而 Nginx 代理的路径为 /hello/(即在 location /hello/ 内设置代理)
则不以 / 结尾的被代理服务器收到的请求路径是 /hello/world
以 / 结尾的被代理服务器收到的请求路径是 /world
如果是为了在同一个域名下...阅读全文>>
Linux下有命令dos2unix
你只要输入dos2unix *.sh就可以完成转换工作了
如果命令不存在的话就用如下命令安装
yum install dos2unix -y阅读全文>>
yum 的使用是很方便的,可能出现的问题就是源的下载速度不理想,所以需要更换。它的配置文件在 /etc/yum.conf,源列表在 /etc/yum.repos.d。
备份mv base.repo baserepo.repo.backup
wget -o base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或http://mirrors.aliyun.com/repo/Centos-6.repo
最后
接下来是生成缓存,yum ...阅读全文>>
"@babel/core": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"@babel/runtime": "^7.3.4",
"babel-loader": "^8.0.5"
.babelrc:
{
"presets":[
["@babel/preset-env",{
"targets":{
"browsers":[">1%","last 2...阅读全文>>