GithubHelp home page GithubHelp logo

aesthetlc / -demo--weibo-easy-realize Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 15 KB

实现新浪微博的增删(利用localStorage存储到浏览器中,实现刷新不清空的效果)

HTML 100.00%

-demo--weibo-easy-realize's Introduction

Weibo easy realize

实现新浪微博的增删(利用localStorage存储到浏览器中,实现刷新不清空的效果)

思路:

  • DOM节点操作:在点击删除的时候,把对应li从ul里面移除
  • 本地化数据更新:删除对应的那条数据及整个列表数组,那我怎么知道我要删除哪个?
    • 唯一的ID:
      • ID:identification身份证,保证该数据绝对的唯一,我们就能找到它;
      • 构成:采用 时间戳+随机数,基本可以保证不会重复;
    • 生成ID,在发布阶段生成:
      • 新增DOM节点,修改DOM节点内容同时,把新增的ID通过赋值为自定义属性的方式加进去;
      • 本地数据,把ID存进去;
    • 删除:有了发布时新增的ID,点击删除时,获取点击对象的自定义属性ID,
      • DOM去除:删除DOM,
      • 数据去除:根据唯一的ID去找当前的数组内的数据,剔除掉;完成更新本地数据;

案例效果:

Image text

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.