Home  >  Article  >  Web Front-end  >  How to get an element in uniapp

How to get an element in uniapp

coldplay.xixi
coldplay.xixiOriginal
2020-12-15 16:10:2313207browse

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
            },

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!

Statement:
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