JS-记事本(代码)

JS-记事本(代码)

提示:该代码可直接使用,点击左边“+”号,新建一个记事本,在左边输入标题及标题后,点击保存,即会生成一个新的记事本,点击已有的记事本,可以对其进行编辑,编辑后可重新进行保存。(在没有需要编辑的记事本内容时,左边所有按钮不可用)
在这里插入图片描述
其中所使用的记事本图标:
在这里插入图片描述
也可根据自己需求自定义。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        *{
   
            box-sizing: border-box;
        }
        ul{
   
            margin: 0;
            padding: 0;
            list-style: none;
        }
        body,p{
   
            margin: 0;
        }
        .all{
   
            width: 100vw;
            height: 100vh;
            padding: 60px;
            display: flex;
        }
        .all aside{
   
            width: 300px;
            border: 1px #000 solid;
            height:100%;
            margin-right: 40px;
            padding: 20px;
        }
        .all aside input,.all aside textarea{
   
            width: 100%;
        }
        .all aside textarea{
   
            resize: none;
            height: 300px;
        }
        .btn{
   
            display: flex;
            height: 100px;
            justify-content: space-between;
            align-items: center;
        }
        .all button{
   
            width: 120px;
            height: 40px;
            border-radius: 15px;
            font-size: 26px;
        }
        .content{
   
            flex: 1;
            height:100%;
            border: 1px #000 solid;
            padding: 20px;
            overflow: hidden;
        }
        .text_list li{
   
            width: 120px;
            float: left;
            margin: 0 
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
微信小程序记事本代码可以分为前端和后端两部分。前端部分主要负责用户界面的展示和交互,后端部分则处理数据的存储和读取。 前端代码示例: ```javascript // pages/index/index.js Page({ data: { notes: [], // 存储笔记列表 inputText: '', // 输入框内容 }, onLoad() { // 页面加载时从后端获取笔记列表 this.getNotes(); }, getNotes() { // 调用后端接口获取笔记列表 wx.request({ url: '后端接口地址', success: (res) => { this.setData({ notes: res.data, }); }, }); }, addNote() { // 添加笔记 const newNote = { content: this.data.inputText, time: new Date().getTime(), }; wx.request({ url: '后端接口地址', method: 'POST', data: newNote, success: () => { this.setData({ inputText: '', }); this.getNotes(); }, }); }, deleteNote(e) { // 删除笔记 const noteId = e.currentTarget.dataset.id; wx.request({ url: `后端接口地址/${noteId}`, method: 'DELETE', success: () => { this.getNotes(); }, }); }, }); ``` 后端代码示例: ```javascript // app.js const express = require('express'); const app = express(); const bodyParser = require('body-parser'); const fs = require('fs'); app.use(bodyParser.json()); // 获取笔记列表 app.get('/notes', (req, res) => { const notes = JSON.parse(fs.readFileSync('notes.json', 'utf8')); res.json(notes); }); // 添加笔记 app.post('/notes', (req, res) => { const notes = JSON.parse(fs.readFileSync('notes.json', 'utf8')); const newNote = req.body; notes.push(newNote); fs.writeFileSync('notes.json', JSON.stringify(notes)); res.sendStatus(200); }); // 删除笔记 app.delete('/notes/:id', (req, res) => { const notes = JSON.parse(fs.readFileSync('notes.json', 'utf8')); const noteId = req.params.id; const updatedNotes = notes.filter((note) => note.time !== parseInt(noteId)); fs.writeFileSync('notes.json', JSON.stringify(updatedNotes)); res.sendStatus(200); }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); ``` 以上代码仅为示例,实际开发中还需要根据具体需求进行适当的修改和完善。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值