VueJS中的数组循环所有空值函数

时间:2019-06-18 02:56:06

标签: mysql vue.js stored-procedures arraylist foreach

我想过滤所有具有 last_login = null 的array_values。如何在VueJS中将数组中的值循环并存储到变量以及上述 last_login = null 数据中?

要过滤的数组值存储在此处: console.log('this is list',this.list)

    methods: {
        checkboxNullLogin(){
            try {
                this.searchTrigger = true
                    var output = [];
                    for (var i=0; i < this.newval.length ; ++i){
                    output.push(this.newval[i]);
                    return output;

                    console.log('TEST Null logins',this.output);

            }
    },
    computed: {
        filteredList(){
            try {
                    this.searchTrigger = true
                    this.analyzeValue = []
                    this.analyzeValue = this.newval
                    this.searchInfo()
                    this.loadList(this.analyzeValue)
                    return this.analyzeValue;
                    }else{
                        this.filter = false
                        this.getAllItems()
                        this.searchTrigger = false
                        return null;
                    }
                }
            }

Pageview.Vue

<!--addedtest-->
  <div class="col-md-4 pdashForm1">
       <div class="cbox" v-for="nologin in filterLogin" v-bind:key="nologin">
            <label>NO LOGINS<br>
                <input type="checkbox" v-model="search.nullLogin" v-bind:value="nologin" v-onclick>
                <span class="checkmark"></span>
            </label>
         </div> 
    </div>

数据库表:

+----------------------+------------------+------+-----+---------+----------------+
| Field                | Type             | Null | Key | Default | Extra          |
+----------------------+------------------+------+-----+---------+----------------+
| id                   | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| first_name           | varchar(255)     | YES  |     | NULL    |                |
| last_name            | varchar(255)     | NO   |     | NULL    |                |
| email                | varchar(255)     | NO   | UNI | NULL    |                |
| password             | varchar(255)     | NO   |     | NULL    |
| 
| last_login           | timestamp        | YES  |     | NULL    |                |             |
| status               | tinyint(4)       | YES  |     | 1       |                |
+----------------------+------------------+------+-----+---------+----------------+

1 个答案:

答案 0 :(得分:0)

让nullValues = yourArray.filter(eachArrayItem => eachArrayItem === null)