前端list.push,封装多个对象

js

javascript 复制代码
   var fruit = ['apple', 'banana'];
	fruit.push('pear');
  console.log(fruit); // ['apple', 'banana', 'pear']

现在为对象

复制代码
        data1:
        {
            addUser: '1',
            editUser: '1',
            addTime: null,
            editTime: 1527410579000,
            userId: 3,
            systemNo: 'mc',
            userName: 'zengzhuo',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRealName: '系统管理员',
            userSex: 'M',
            userMobile: '18616988966',
            userEmail: '222@qq.com',
            isLock: 'N',
            deptId: 2,
            deptName: 'xxxx',
            roleId: 101
          },
        data2: 
          {
            addUser: '1',
            editUser: '1',
            addTime: null,
            editTime: 1527411068000,
            userId: 1,
            systemNo: 'pmd',
            userName: 'root',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRealName: '超级管理员',
            userSex: '女',
            userMobile: '138123456789',
            userEmail: '111@qq.com',
            isLock: 'N',
            deptId: 1,
            deptName: 'xxxx',
            roleId: 1
          },
js 复制代码
  var data0 = []
  data0.push(this.data1,this.data2)
console.log(data0)

整体代码

vue 复制代码
<template>
    <div id="app">
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
    </div>
</template>
  
<script>
export default {
    name: "App",
    data() {
    return {
        data1:
        {
            addUser: '1',
            editUser: '1',
            addTime: null,
            editTime: 1527410579000,
            userId: 3,
            systemNo: 'mc',
            userName: 'zengzhuo',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRealName: '系统管理员',
            userSex: 'M',
            userMobile: '18616988966',
            userEmail: '222@qq.com',
            isLock: 'N',
            deptId: 2,
            deptName: 'xxxx',
            roleId: 101
          },
        data2: 
          {
            addUser: '1',
            editUser: '1',
            addTime: null,
            editTime: 1527411068000,
            userId: 1,
            systemNo: 'pmd',
            userName: 'root',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRealName: '超级管理员',
            userSex: '女',
            userMobile: '138123456789',
            userEmail: '111@qq.com',
            isLock: 'N',
            deptId: 1,
            deptName: 'xxxx',
            roleId: 1
          },
          data3:[]
    }},
    methods: {
        //test事件
        search() {
            var fruit = ['apple', 'banana'];
            fruit.push('pear');
            console.log(fruit); // ['apple', 'banana', 'pear']

            fruit.push('orange', 'grape',this.data2);
            console.log(fruit); // ['apple', 'banana', 'pear', 'orange', 'grape']

           
       var data0 = []
       data0.push(this.data1,this.data2)
          
          console.log(data0)
        }
    }
};

</script>
  
<style> html,
 body {
     width: 100%;
     height: 100%;
     box-sizing: border-box;
     padding: 0px;
     margin: 0px;
 }

 #app {
     font-family: "Avenir", Helvetica, Arial, sans-serif;
     -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
     color: #2c3e50;
     widows: 100%;
     height: 100%;
 }
</style>
  
相关推荐
武子康8 分钟前
Search Console Platform Properties 扩大 SEO 资产边界:从 Page Ranking 到 Topic Coverage(5 类误读边界 + 3 表数据层设计)
前端·人工智能·后端
一点一木1 小时前
从60首歌到1个网站:输入你的故事,还你一首歌
前端·github
IT_陈寒2 小时前
Vue这个特性差点让我加班到凌晨,谁懂啊
前端·人工智能·后端
kyriewen2 小时前
我让AI改一个bug——它偷偷动了5个我没让它碰的地方
前端·javascript·ai编程
遇乐的果园3 小时前
前端学习笔记-vue加载渲染优化
前端·笔记·学习
用户985033593283 小时前
OpenLayers 热力图从原理到 Vue 组件一键接入
前端
颜酱3 小时前
01 | 骨架搭建:FastAPI + Vue 跑通第一个 SSE 流式问答
前端·人工智能·后端
hoLzwEge3 小时前
解码 IDE 智能提示:jsconfig.json 辅助开发全攻略
前端·前端框架
leoZ2313 小时前
记忆系统与 Agent 定制完全指南(四):自定义 Agent 开发(一)
前端·chrome
慧一居士4 小时前
Element Plus 按需引入的配置使用说明和完整示例
前端·vue.js