Home > Web Front-end > uni-app > body text

How to get an element in uniapp

coldplay.xixi
Release: 2023-01-13 00:44:24
Original
13203 people have browsed it

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].

How to get an element in uniapp

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 == &#39;2&#39;){
                            let x = this.model_list[i].dataset.model
                            console.log(this[`${x}`])
                            // if(){}
                            //验证是否为空
                            if (this[`${x}`] == &#39;&#39;) {
                                return false
                            }
                        }
                    }
                }
                return true
            },
            //获取所有必填项的列表
            get_must() {
                console.log("**************************------------------******************************")
                const query = uni.createSelectorQuery().in(this);
                query.selectAll(&#39;.must&#39;).fields({
                    dataset: true,
                }, data => {
                    this.model_list = data
                    console.log(data)
                }).exec();
                
                console.log("**************************------------------******************************")
                return true
            },
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template