1、静态资源服务器搭建
1 /*加载模块*/ 2 var express = require(‘express‘); 3 var http = require(‘http‘); 4 var path = require(‘path‘); 5 /*创建服务*/ 6 var app = express(); 7 app.set(‘port‘, 80); 8 app.use(express.static(path.join(__dirname, ‘public‘))); 9 /*服务启动*/ 10 http.createServer(app).listen(app.get(‘port‘), function() { 11 console.log(‘静态资源服务器已启动,监听端口:‘ + app.get(‘port‘)); 12 });
2、PM2能否运行npm start
https://stackoverflow.com/questions/31579509/can-pm2-run-an-npm-start-script
(1) 原生支持
pm2 start npm -- start
(2) shell脚本
wrote shell script below (named start.sh). Because my package.json has prestart option. So I want to run npm start.
1 #!/bin/bash 2 cd /path/to/project 3 npm start
Then, start start.sh by pm2.
pm2 start start.sh --name appNameYouLike
3、开发注意事项
1)环境变量 env
分别是 development,testing,production,对应开发,测试和线上,统一通过PHP打到js变量env中。
可以使用这些变量来控制api的地址,比如如下:
var api_base = (env === ‘production‘) ? ‘//open.che300.com‘ : ‘//open.ceshi.che300.com‘;
2)HTTP和HTTPS问题
我们页面中的前端资源和访问的接口,都统一配置成 // 开头,来根据实际域名切换http协议。
<script type="text/javascript" src="//fezz.che300.com/cves/wap/dist/lib/js/jquery-1.9.1.min.js?v=297"></script>
4、How to remove a auto hyperlinked phone number from Microsoft Edge
https://stackoverflow.com/questions/31867068/how-to-remove-a-auto-hyperlinked-phone-number-from-microsoft-edge
The solution that works for iOS devices also works for Microsoft Edge.
Adding the meta tag,
<meta name="format-detection" content="telephone=no">
will prevent the DOM document from being modified when parsed by the browser.
5、Disabling chrome autofill
https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
autocomplete="off" ---- to ---- autocomplete="false"