布局
<el-radio-button @click.native="alls('todo')" label="2">全部</el-radio-button>
<el-radio-button @click.native="alls('unfinish')" label="0">未完成</el-radio-button>
<el-radio-button @click.native="alls('finished')" label="1">完成</el-radio-button>
代码
alls(name) {
this.$router.push({
name
})
},
根据上面的时间执行,跳转路由的路径
watch: {
$route: {
immediate: true,
handler(value) {
console.log(value)
switch (value.name) {
case “todo”:
this.typeNum = 2
break;
case “finished”:
this.typeNum = 1
break;
case “unfinish”:
this.typeNum = 0
break;
}
}
}
},
监听路由 在点击name的值等于啥时触发啥
布局
<span
class="con"
@click="changeStatus(item.id)"
:class="{finished:item.finished}"
>{{item.val}}</span>
<el-button type="primary" @click="deleteItems(item.id)">删除</el-button>
代码
computed: {
todolist() {
// console.log(typeof this.typeNum)
if (this.typeNum === 1) {
return this.KaTeX parse error: Expected 'EOF', got '}' at position 56: ….finished) }̲ else if (this.…store.state.todolist.filter(item => !item.finished)
} else {
return this.$store.state.todolist
}
}
},
根据上面的代码 触发时间 筛选响应的东西