업무 케이스

17331 단어 vue
#첫 페이지#



export default</span> <span class="token punctuation">{</span>
    <span class="token selector">data()</span><span class="token punctuation">{</span>
        <span class="token selector">return</span><span class="token punctuation">{</span>
            <span class="token property">value</span><span class="token punctuation">:</span><span class="token string">""</span>,
            <span class="token property">list</span><span class="token punctuation">:</span>[],
            <span class="token property">isceuu</span><span class="token punctuation">:</span>-1,
            <span class="token property">itemval</span><span class="token punctuation">:</span><span class="token string">""</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token selector">,
    created()</span><span class="token punctuation">{</span>
        let todolist=localStorage.todolist<span class="token selector">;
        if(this.list)</span><span class="token punctuation">{</span>
            this.list=JSON.<span class="token function">parse</span><span class="token punctuation">(</span>todolist<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token selector">,
    computed:</span><span class="token punctuation">{</span>
        <span class="token selector">nolist()</span><span class="token punctuation">{</span>
            <span class="token selector">let num=0
            this.list.map(item=></span><span class="token punctuation">{</span>
                <span class="token selector">if(!item.is)</span><span class="token punctuation">{</span>
                num++<span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
            return num
        <span class="token punctuation">}</span><span class="token selector">,
         yeslist()</span><span class="token punctuation">{</span>
            <span class="token selector">let num=0
            this.list.map(item=></span><span class="token punctuation">{</span>
                <span class="token selector">if(item.is)</span><span class="token punctuation">{</span>
                num++<span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
            return num
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token selector">,
    methods:</span><span class="token punctuation">{</span>
        <span class="token selector">add()</span><span class="token punctuation">{</span>
            <span class="token selector">this.list.push(</span><span class="token punctuation">{</span>
                <span class="token property">val</span><span class="token punctuation">:</span>this.value,
                <span class="token property">is</span><span class="token punctuation">:</span>false
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
            this.value=<span class="token string">""</span>
            this.<span class="token function">save</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token selector">,
        sadd(item)</span><span class="token punctuation">{</span>
            item.is=true<span class="token punctuation">;</span>
            this.<span class="token function">save</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token selector">,
        yadd(item)</span><span class="token punctuation">{</span>
            item.is=false<span class="token punctuation">;</span>
            this.<span class="token function">save</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token selector">,
        del(index)</span><span class="token punctuation">{</span>
            this.list.<span class="token function">splice</span><span class="token punctuation">(</span>index,1<span class="token punctuation">)</span>
            this.<span class="token function">save</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token selector">,
        dblist(item,index)</span><span class="token punctuation">{</span>
            this.isceuu=index<span class="token punctuation">;</span>
            this.itemval=item.val
            this.<span class="token function">save</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token selector">,
        updata()</span><span class="token punctuation">{</span>
            this.isceuu = -1
            this.<span class="token function">save</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token selector">,
        back(item)</span><span class="token punctuation">{</span>
            item.val=this.itemval
            this.itemval=<span class="token string">""</span><span class="token punctuation">;</span>
            this.isceuu = -1
        <span class="token punctuation">}</span><span class="token selector">,
        save()</span><span class="token punctuation">{</span>
            localStorage.todolist=JSON.<span class="token function">stringify</span><span class="token punctuation">(</span>this.list<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token selector">




레이스 페이지
  

  • {{item.val}}
export default { data(){ return{ sel:"0", list:[], lists:[], kw:"" } }, watch:{ sel(vals){ console.log(vals) this.lists=[] switch(vals){ case "0": this.lists=[]; break; case "1": this.lists=this.list break; case "2": this.list.map(item=>{ if(item.is){ this.lists.push(item) } }) break; case "3": this.list.map(item=>{ if(!item.is){ this.lists.push(item) } }) break; } } }, created(){ let list=localStorage.todolist if(list){ this.list=JSON.parse(list) } }, methods:{ sraech(){ this.lists=[]; this.list.map(item=>{ if(item.val.includes(this.kw)){ this.lists.push(item) } }) this.kw="" } } }

좋은 웹페이지 즐겨찾기