vue数组进行分组
数组进行分组使用switch方法
<template>
<v-layout>
<v-card contextual-style="dark" v-if="show">
<span slot="header">
一级主页面
</span>
<div slot="body">主内容页
<!-- <div v-for="item in listTittle" :key="item.id">{{item}}</div> -->
<!-- <div v-for="item in list" :key="item.id">
<p>{{listTittle}}{{item.name }}</p>
</div> -->
<div>
<ul>
<li>需求:{{lists.demand}}</li>
<li>用户:{{lists.user}}</li>
<li>时间:{{lists.time}}</li>
</ul>
</div>
</div>
<div slot="footer" :showDate="showDate">
<div>来自主页面</div>
<button type="button" class="btn btn-info " @click="toggle1">去子组件并传递数据</button>
</div> </v-card>
<v-card contextual-style="dark" v-else>
<span slot="header">
组件主页
</span>
<div slot="body">组件内容页</div>
<div slot="footer">
<div>来自组件页面</div>
<my-button showDate="***父组件传递的数据***" @toggleEvent="toggle"></my-button>
</div> </v-card> </v-layout>
</template> <script>
/* ============
* Home Index Page
* ============
*
* The home index page.
*/ import VLayout from '@/layouts/Default';
import VCard from '@/components/Card';
import MyButton from '@/components/MyButton'; export default {
/**
* The name of the page.
*/
name: 'home-index',
data() {
return {
show: true,
showDate: "父子间传过来的数据",
lists: {
demand: [],
user: [],
time: []
},
list: [{ id: 1, name: '需求1', code: 'admin.demand' },
{ id: 2, name: '需求2', code: 'admin.demand' },
{ id: 3, name: '用户1', code: 'admin.user' },
{ id: 4, name: '用户2', code: 'admin.user' },
{ id: 5, name: '时间1', code: 'admin.time' },
{ id: 6, name: '时间2', code: 'admin.time' },
{ id: 7, name: '用户3', code: 'admin.user' },]
}
},
methods: {
toggle1() {
this.show = false;
},
toggle(data) {
console.log(data)
this.show = data;
},
listinfo() { this.list.map((x) => {
console.log(x.code.split(".")[1])
switch (x.code.split(".")[1]) {
case "demand":
this.lists.demand.push(x.name);
// 执行代码块 1
break;
case "user":
// 执行代码块 2
this.lists.user.push(x.name);
break;
case "time":
// 执行代码块 3
this.lists.time.push(x.name);
break;
default: }
})
}
},
mounted() {
// this.toggle();
this.listinfo();
},
/**
* The components that the page can use.
*/
components: {
VLayout,
VCard,
MyButton
},
};
</script>
vue数组进行分组的更多相关文章
- [one day one question] Vue数组变更不能触发刷新
问题描述:Vue数组变更不能触发刷新,特别是数组的每个元素都是对象的时候,对象中某个属性的值发生变化,根本无法触发Vue的dom刷新,这怎么破? 解决方案:this.$set(array, index ...
- vue 数组渲染问题
vue 数组渲染问题 问题一: 用v-for循环渲染数组数据时,数据更新了,视图却没有更新 由于 JavaScript 的限制, Vue 不能检测以下变动的数组: 1. 当你利用索引直接设置一个项时, ...
- vue数组变异方法
Vue数组变异方法,会改变被这些方法调用的原始数组,将会触发视图更新 push() 接收任意数量的参数,把它们逐个添加到数组末尾,并返回修改后数组的长度 pop() 从数组末尾移除最后一项,减少数组的 ...
- Vue数组更新及过滤排序
前面的话 Vue为了增加列表渲染的功能,增加了一组观察数组的方法,而且可以显示一个数组的过滤或排序的副本.本文将详细介绍Vue数组更新及过滤排序 变异方法 Vue 包含一组观察数组的变异方法,它们将会 ...
- vue 数组 新增元素 响应式原理 7种方法
1.问题 思考一个问题,以下代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- vue 数组更新 this.$set(this.dataList, data.index, data.data)
vue 数组更新 this.$set(this.dataList, data.index, data.data) https://www.cnblogs.com/huangenai/p/9836811 ...
- vue 数组和对象渲染问题
vue 数组和对象渲染问题 最近项目有点忙碌,遇到好多问题都没有总结(╥﹏╥),在开发过程中,取vuex中的数组渲染完成之后,再次修改数组的值,数据更新了,但是视图并没有更新.以为是数组更新的问题,后 ...
- vue 数组对接字符串 传值时候,join(',') 一下 watch
vue 数组对接字符串 传值时候,join(',') 一下 watch watch: { 'tFill.otherDescArr': function (newVal, oldVal) { this. ...
- vue数组更新界面无变化
1. vue数组更新界面无变化 1.1. 说明 对数组进行更新或者添加,一定要注意方式,我的情况是数组套数组,双重循环,在造数据的时候,不断从尾部添加数据,所以写成了如下形式,每次下拉都会去加载一批相 ...
随机推荐
- Android-隐式意图激活操作系统通话界面
阅读Android操作系统的 packages/apps/phone/AndroidManifest.xml,是如何暴露的 AndroidManifest.xml Android操作系统在这里明确 ...
- Spring 事务管理案例
事务管理简介 Spring 事务管理有两种方式:一种是编程式事务管理,即通过编写代码实现事物管理,包括定义事务的开始,程序正常执行后的事物提交,异常时进行的事务回滚.另一种是基于AOP技术实现的声 ...
- yum初识
yum仓库中的元数据文件: primary.xml.gz 所有RPM包的列表: 依赖关系: 每个RPM安装生成的文件列表: filelists.xml.gz 当前仓库中所有RPM包的所有文件列表: o ...
- vim编辑后权限不够保存问题解决方案
常常忘记了sudo就直接用vim编辑/etc内的文件,等编辑好了,保存时候才发现没权限. 1.曲线救国:先保存个临时文件,退出后再sudo cp回去 2.可以直接用 :w !sudo tee % 查阅 ...
- Asp.net Core IIS上安装部署及502.5错误解决
总结: 安装Microsoft Visual C++ 2015 Redistributable(https://www.microsoft.com/en-us/download/details.asp ...
- zun 不能创建 docker 容器,报错: datastore for scope "global" is not initialized
问题:zun不能创建docker容器,报错:datastore for scope "global" is not initialized 解决:修改docker 服务配置文件 ...
- 【Oracle 12c】CUUG OCP认证071考试原题解析(35)
35.choose the best answer View the Exhibit and examine the description of the EMPLOYEES table. Evalu ...
- [ActionScript3.0] 使用FileReference处理单个文件的上载
package { import flash.display.SimpleButton; import flash.display.Sprite; import flash.errors.Illega ...
- JMeter PerfMon Metrics Collector性能监控插件
官方文档地址https://jmeter-plugins.org/wiki/PerfMon/ JMeter是一款压力测试工具,我们也可以用它来监控服务器资源使用情况. JMeter正常自带可以通过To ...
- dbporxy-mysql 协议流转图
dbproxy 支持 in 查询, 当in 中的字段 属于不同的分表时, QPS约为 5000左右, 如果为 等值查询, qps的30000左右 主要原因是 对于in操作,会产生多个不同分表的sql ...