uniapp如何获取某个元素

发布时间:2022-05-23 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了uniapp如何获取某个元素脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

uniapp获取某个元素的方法:1、表单验证,验证是否为空,代码为【if (this[`${x}`] == '') {return false}】;2、获取所有必填项的列表,代码为【const query = uni.createSel】。

uniapp如何获取某个元素

本教程操作环境:windows7系统、uni-app2.5.1版本,Dell G3脑。

uniapp获取某个元素的方法:

//表单验证
            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
            },

相关免费学习推荐:PHP编程(视频)

推荐(免费):uni-app开发教程

以上就是uniapp如何获取某个元素的详细内容,更多请关注脚本宝典其它相关文章

脚本宝典总结

以上是脚本宝典为你收集整理的uniapp如何获取某个元素全部内容,希望文章能够帮你解决uniapp如何获取某个元素所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。