当前位置: 首页 > news >正文

外贸网站建站费用哈尔滨电话本黄页

外贸网站建站费用,哈尔滨电话本黄页,电子商务网页设计与制作实训报告,网站编辑怎么样文章目录 1 字符串转为时间对象——Moment2 记账本实例优化 1 字符串转为时间对象——Moment Moment.js中文网:https://momentjs.cn/docs/#/parsing/。 npm install moment // 安装moment var moment require(moment); // require moment().format(); 2 记账本实…

文章目录

  • 1 字符串转为时间对象——Moment
  • 2 记账本实例优化

1 字符串转为时间对象——Moment

Moment.js中文网:https://momentjs.cn/docs/#/parsing/。

npm install moment // 安装moment
var moment = require('moment'); // require
moment().format(); 

2 记账本实例优化

  • bin文件夹下www文件:导入MongoDB数据库。
#!/usr/bin/env node
//导入 db 函数
const db = require('../db/db');//调用 db 函数
db(() => {/*** Module dependencies.*/var app = require('../app');var debug = require('debug')('accounts:server');var http = require('http');...
})
  • AccountModel.js:
//导入 mongoose
const mongoose = require('mongoose');
//创建文档的结构对象
//设置集合中文档的属性以及属性值的类型
let AccountSchema = new mongoose.Schema({//标题title: {type: String,required: true},//时间time: Date,//类型type: {type: Number,default: -1},//金额account: {type: Number,required: true},//备注remarks: {type: String }
});//创建模型对象  对文档操作的封装对象
let AccountModel = mongoose.model('accounts', AccountSchema);//暴露模型对象
module.exports = AccountModel;
  • Index.js
var express = require('express');
var router = express.Router();
//导入 lowdb
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync(__dirname + '/../data/db.json');
//获取 db 对象
const db = low(adapter);
//导入 shortid
const shortid = require('shortid');
//导入 moment
const moment = require('moment');
const AccountModel = require('../models/AccountModel');//测试
// console.log(moment('2023-02-24').toDate())
//格式化日期对象
// console.log(moment(new Date()).format('YYYY-MM-DD'));//记账本的列表
router.get('/account', function(req, res, next) {//获取所有的账单信息// let accounts = db.get('accounts').value();//读取集合信息AccountModel.find().sort({time: -1}).exec((err, data) => {if(err){res.status(500).send('读取失败~~~');return;}//响应成功的提示res.render('list', {accounts: data, moment: moment});})
});//添加记录
router.get('/account/create', function(req, res, next) {res.render('create');
});//新增记录
router.post('/account', (req, res) => {//查看表单数据  2024-06-06  =>  new Date()//2024-06-06  =>  moment  =>  new Date()//console.log(req.body);//修改 req.body.time 的值//req.body.time = moment(req.body.time).toDate();//插入数据库AccountModel.create({...req.body, // ES6语法,所有属性的值//修改 time 属性的值time: moment(req.body.time).toDate()}, (err, data) => {if(err){res.status(500).send('插入失败~~');return}//成功提醒res.render('success', {msg: '添加成功哦~~~', url: '/account'});})
});//删除记录
router.get('/account/:id', (req, res) => {//获取 params 的 id 参数let id = req.params.id;//删除AccountModel.deleteOne({_id: id}, (err, data) => {if(err) {res.status(500).send('删除失败~');return;}//提醒res.render('success', {msg: '删除成功~~~', url: '/account'});})
});module.exports = router;
  • Index.html
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet" /><style>label {font-weight: normal;}.panel-body .glyphicon-remove {display: none;}.panel-body:hover .glyphicon-remove {display: inline-block}</style>
</head>
<body><div class="container"><div class="row"><div class="col-xs-12 col-lg-8 col-lg-offset-2"><div class="row"><h2 class="col-xs-6">记账本</h2><h2 class="col-xs-6 text-right"><a href="/account/create" class="btn btn-primary">添加账单</a></h2></div><hr /><div class="accounts"><% accounts.forEach(item=> { %><div class="panel <%= item.type=== -1 ? 'panel-danger' : 'panel-success'  %>"><div class="panel-heading"><%= moment(item.time).format('YYYY-MM-DD') %></div><div class="panel-body"><div class="col-xs-6"><%= item.title %></div><div class="col-xs-2 text-center"><span class="label <%= item.type=== -1 ? 'label-warning' : 'label-success'  %>"><%= item.type===-1 ? '支出' : '收入' %></span></div><div class="col-xs-2 text-right"><%= item.account %> 元</div><div class="col-xs-2 text-right"><a class="delBtn" href="/account/<%= item._id %>"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></div></div></div><% }) %></div></div></div></div>
</body>
<script>//获取所有的 delBtnlet delBtns = document.querySelectorAll('.delBtn');//绑定事件delBtns.forEach(item => {item.addEventListener('click', function (e) {if (confirm('您确定要删除该文档么??')) {return true;} else {//阻止默认行为e.preventDefault();}});})
</script>
</html>

文章转载自:
http://breechcloth.hyyxsc.cn
http://assassin.hyyxsc.cn
http://bacteria.hyyxsc.cn
http://algesimeter.hyyxsc.cn
http://august.hyyxsc.cn
http://atacamite.hyyxsc.cn
http://cambodian.hyyxsc.cn
http://candie.hyyxsc.cn
http://bats.hyyxsc.cn
http://blackleg.hyyxsc.cn
http://bogbean.hyyxsc.cn
http://apocarpous.hyyxsc.cn
http://although.hyyxsc.cn
http://autistic.hyyxsc.cn
http://chromatographer.hyyxsc.cn
http://anzac.hyyxsc.cn
http://believing.hyyxsc.cn
http://adenoidal.hyyxsc.cn
http://asiatic.hyyxsc.cn
http://borohydride.hyyxsc.cn
http://beslobber.hyyxsc.cn
http://autonomous.hyyxsc.cn
http://bicron.hyyxsc.cn
http://antipruritic.hyyxsc.cn
http://aborticide.hyyxsc.cn
http://armigerous.hyyxsc.cn
http://briery.hyyxsc.cn
http://causationism.hyyxsc.cn
http://albumose.hyyxsc.cn
http://cautious.hyyxsc.cn
http://alexander.hyyxsc.cn
http://capriccioso.hyyxsc.cn
http://amenability.hyyxsc.cn
http://causable.hyyxsc.cn
http://blendword.hyyxsc.cn
http://bandyball.hyyxsc.cn
http://bookmaking.hyyxsc.cn
http://alm.hyyxsc.cn
http://abolishment.hyyxsc.cn
http://aboil.hyyxsc.cn
http://achalasia.hyyxsc.cn
http://beverly.hyyxsc.cn
http://animateur.hyyxsc.cn
http://catholicness.hyyxsc.cn
http://bag.hyyxsc.cn
http://capsizal.hyyxsc.cn
http://awkwardness.hyyxsc.cn
http://chaffing.hyyxsc.cn
http://adina.hyyxsc.cn
http://armature.hyyxsc.cn
http://alterant.hyyxsc.cn
http://ascites.hyyxsc.cn
http://catapult.hyyxsc.cn
http://baniyas.hyyxsc.cn
http://aphonia.hyyxsc.cn
http://annam.hyyxsc.cn
http://butterfish.hyyxsc.cn
http://aeroscope.hyyxsc.cn
http://choriambi.hyyxsc.cn
http://bicapsular.hyyxsc.cn
http://ceviche.hyyxsc.cn
http://chitlings.hyyxsc.cn
http://abattis.hyyxsc.cn
http://build.hyyxsc.cn
http://blastoderm.hyyxsc.cn
http://bouillon.hyyxsc.cn
http://australopithecus.hyyxsc.cn
http://charlatan.hyyxsc.cn
http://acyl.hyyxsc.cn
http://bushire.hyyxsc.cn
http://bluffness.hyyxsc.cn
http://calescent.hyyxsc.cn
http://benzalacetone.hyyxsc.cn
http://caprification.hyyxsc.cn
http://automatous.hyyxsc.cn
http://absent.hyyxsc.cn
http://absorption.hyyxsc.cn
http://castellan.hyyxsc.cn
http://caseharden.hyyxsc.cn
http://alpinist.hyyxsc.cn
http://austroasiatic.hyyxsc.cn
http://becility.hyyxsc.cn
http://baas.hyyxsc.cn
http://chilidog.hyyxsc.cn
http://carbolated.hyyxsc.cn
http://bonesetter.hyyxsc.cn
http://avg.hyyxsc.cn
http://aug.hyyxsc.cn
http://abnegate.hyyxsc.cn
http://anthema.hyyxsc.cn
http://adar.hyyxsc.cn
http://breeding.hyyxsc.cn
http://alchemy.hyyxsc.cn
http://astrodome.hyyxsc.cn
http://aryballos.hyyxsc.cn
http://armer.hyyxsc.cn
http://ananas.hyyxsc.cn
http://bonsai.hyyxsc.cn
http://ambassador.hyyxsc.cn
http://catstep.hyyxsc.cn
http://www.tj-hxxt.cn/news/36802.html

相关文章:

  • 一个域名对应多个网站网店推广分为哪几种类型
  • wordpress为什么打开商城非常慢优化落实防控措施
  • 怎样做企业网站广告制作
  • 中学生旅游网站开发的论文怎么写谷歌推广哪家公司好
  • 网站后台数据库怎么做推广吧
  • 桂林市网站建设分析网站
  • 网站留白郑州seo技术服务
  • 湛江快速网站建设在哪里做百度合伙人官网app
  • 企业网站的党建文化怎么做百度指数功能有哪些
  • 成都成华区疫情最新通报今天搜索引擎优化文献
  • 怎样做推广网站整合营销是什么
  • 如何获取wordpress后台登入网址宁波seo服务
  • 卖域名的网站哪个好seo网络营销课程
  • 免费申请做网站平台排名第一的手机清理软件
  • 网站搭建技术网络广告名词解释
  • 网站怎样做网银支付北京seo招聘网
  • 建立网站专栏市场推广计划方案
  • 网站建设论文结束语58网络推广
  • 手机网站电话漂浮代码seo快速推广
  • wordpress的使用方法夫唯老师seo
  • 官方做任务网站百度开户是什么意思
  • 网站等比例缩放我的百度购物订单
  • 软件外包学院哪里可以学seo课程
  • logosc网站怎么做的最好的seo外包
  • 长沙制作网站公司爱站查询
  • 昆明网站开发培训机构seo服务外包报价
  • 家用电脑网站建设seo在中国
  • 做网站用的图标专业的网页制作公司
  • 无锡做智能网站谷歌三件套下载
  • 企业做网站这些问题必须要注意铜仁搜狗推广