Home > Article > Web Front-end > How to get an element in uniapp
Uniapp's method of obtaining a certain element: 1. Form verification, verify whether it is empty, the code is [if (this[`${x}`] == '') {return false}]; 2 , get the list of all required items, the code is [const query = uni.createSel].
The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.
uniapp's method of obtaining a certain element:
//表单验证 from_judge() { if(this.get_must()){ for (let i = 0; i < this.model_list.length; i++) { console.log(this.model_list[i]) if(this.model_list[i].dataset.must == '2'){ let x = this.model_list[i].dataset.model console.log(this[`${x}`]) // if(){} //验证是否为空 if (this[`${x}`] == '') { return false } } } } return true }, //获取所有必填项的列表 get_must() { console.log("**************************------------------******************************") const query = uni.createSelectorQuery().in(this); query.selectAll('.must').fields({ dataset: true, }, data => { this.model_list = data console.log(data) }).exec(); console.log("**************************------------------******************************") return true },
Related free learning recommendations: php programming (video)
Recommended (free): uni-app development tutorial
The above is the detailed content of How to get an element in uniapp. For more information, please follow other related articles on the PHP Chinese website!