求助:为什么刷新之后重新添加的数据会把之前的数据覆盖?谢谢!

    <form class="add">

            <input type="text" name='content' >

            <input type="submit" value="添加">

   </form>

   <script>

        var $form_add = $('.add');

        var store_thing = [];

        $form_add.submit(function(e){

            var new_thing = {};

            e.preventDefault();

            var $input = $(this).find('input[name=content]');

            new_thing.content = $input.val();

            console.log('new',new_thing);

            add(new_thing);

        })

        function add(new_thing){

        store_thing.push(new_thing);

        store.set('store_thing',store_thing);

        }

        var re = store.get('store_thing');

        console.log('store_thing',re);

   </script>

   

   


肥皂起泡泡
浏览 702回答 1
1回答

大话西游666

你需要在把var&nbsp;store_thing&nbsp;=&nbsp;[];改成从store.get("store_thing")里面拿数据
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript