mysql - VueJS中的数组循环所有空值函数
问题描述
我想过滤我的 array_values 所有那些last_login = null。如何循环数组中的值并将其与 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;
}
}
}
浏览量.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 | |
+----------------------+------------------+------+-----+---------+----------------+
解决方案
让 nullValues = yourArray.filter(eachArrayItem => eachArrayItem === null)
推荐阅读
- django - CSV 阅读器在每行之后放置 /n
- angularjs - 无法从 ng-dropdown-multiselect 指令调用控制器功能
- azure-cognitive-search - 为 Azure 搜索选择正确的分析器
- ios - iOS 辅助功能 – 检测颜色过滤器是否打开?
- javascript - 使用 for 循环切换 div
- java - 尝试获取 Pinterest 访问令牌时出错
- c# - 无法更改属性的值
- swift - CallKit - 如何将 CXCallController 放在前面
- python - Python - 循环中的代码阻塞问题
- .net-core - FluentValidation:模拟 ValidationResult.IsValid