2020.6.27

今日学习内容:

css3:

fliter : blur(); (模糊化)数值越大越模糊

width : clac(100% - 10px); 计算盒子宽度

transition :  width/all   1s/5s   linear(匀速)、ease(逐渐慢下来)、easr-in(加速)、ease-out(ease-out(减速)、ease-in-out(加速)

SEO优化:

TDK:title;description;keywords。

<title>xxx</title>
 <meta name="description" content="xxx" />
    <meta name="keywords" content="xxx" />

node.js:

通过express创建服务器:

app.js(入口函数)、config.js(配置模块)、handler.js(业务模块)、router.js(业务模块)

app.js:

// app.js 模块职责: 负责启动服务

// 1. 加载 express 模块
var express = require('express');
// 加载 config.js 模块
var config = require('./config.js');
// 加载路由模块
var router = require('./router.js');

// 2. 创建 app 对象
var app = express();

// console.log(router.toString()); 


// 3. 注册路由
// 设置 app 与 router 相关联
// app.use('/', router);
app.use(router);

// 4. 启动服务
app.listen(config.port, function () {
    console.log('http://localhost:9092');
})
 
config.js:
// 配置模块,主要职责是负责保存项目中的配置信息
module.exports = {
    port: 9092
};

handler.js:

// 业务模块
var path = require('path');

// 处理新闻列表 index

module.exports.index = function (req, res) {

    // sendFile() 方法虽然可以读取对应的文件并返回,但是我们不使用 sendFile() 方法
    // 原因是: 将来我们要进行 index.html 中的模板代码进行执行并替换 
    // res.sendFile(path.join(__dirname, 'views', 'index.html'));

// 默认 render 方法是不能使用的,需要为 express 配置一个模板引擎,然后才可以使用
    res.render(path.join(__dirname, 'views', 'index.html'));
};
router.js:
// 路由模块,主要负责路由判断


// 1. 创建一个 router 对象 (router 对象既是一个对象,也是一个函数)
var express = require('express');
// 加载业务模块
var handler = require('./handler.js');
var path = require('path');


var router = express.Router();


// 2. 通过 router 对象设置(挂载)路由

router.get('/', handler.index);
router.get('/index', handler.index);


router.get('/submit', function (req, res) {

});

router.get('/item', function (req, res) {

});

router.get('/add', function (req, res) {

});

router.get('/add', function (req, res) {

});


// 实现对 resources 文件夹下的内容进行静态资源托管

router.use('/resources', express.static(path.join(__dirname, 'resources')));


// 3. 通过 router 对象

module.exports = router;

注意:express 的 render() 方法必须挂载一个模板,如 ejs 等




 

猜你喜欢

转载自www.cnblogs.com/cntian/p/13200478.html