업무 케이스
17331 단어 vue
TODOList
({{nolist}})
-
{{item.val}}
({{yeslist}})
-
{{item.val}}
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=""
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Fastapi websocket 및 vue 3(Composition API)1부: FastAPI virtualenv 만들기(선택 사항) FastAPI 및 필요한 모든 것을 다음과 같이 설치하십시오. 생성main.py 파일 및 실행 - 브라우저에서 이 링크 열기http://127.0.0.1:...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.