一加一等于: 2
span: 1 span: 2 span: 3
这是默认主题内置的 <Badge />
组件 演示
<!-- 默认情况下,这里会被保持原样 -->
1 + 2 + 3 = {{ 1 + 2 + 3 }}
<!-- 这里会被 Vue 编译 -->
1 + 2 + 3 = 6
// 由于 JS 代码高亮,这里不会被正确编译
const onePlusTwoPlusThree = {{ 1 + 2 + 3 }}
导入包
const express = require('express');
//导入歌手JSON
const {singers} = require('./singers.json');
const app = express();
处理JSON
app.get('/singer/:id.html', (req,res) => {
//获取路由参数
let {id} = req.params;
//在数组中寻找对应ID的数据
let result = singers.find(item => {
if (item.id === Number(id)) {
return true;
}
});
//判断
if (!result){
res.statusCode = 404;
res.,end(`<h1>404 Not Fount</h1>`);
return;
}
res.end(`
<!DOCTYPE HTML>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>标题</title>
</head>
<body>
<h2>${result.singer_name}</h2>
<img scr='${result.singer_pic}'/>
</body>
</html>
`)
});
开启服务
app.listen(3000, () => {
consloe.log('服务启动,端口监听中。')
});