F
F
feniksdv2020-10-19 10:29:40
Vue.js
feniksdv, 2020-10-19 10:29:40

How to check VUE innerText for null or ' '?

Hello. I want to check innerText for an empty value or zero, but something doesn't work for me. here is a piece of code.

color: function () {
                axios.get('/show/' + this.site.site + '/getJson/1').then((response) => {
                    this.urldata = response.data;
                    for (let j = 0; j<this.$refs.tr.length; j++) {
                        for (let i = 1; i < this.$refs.tr[j].cells.length-1; i++) {
                            if (this.$refs.tr[j].cells[i].innerText === '') { //тут проверка, не работает почему-то
                                this.$refs.tr[j].cells[i + 1].bgColor = "#ffffff";
                                console.log('1');
                                this.errors.push('1');
                            }
                            else if (this.$refs.tr[j].cells[i].innerText === null) { //тут проверка, не работает почему-то
                                this.$refs.tr[j].cells[i + 1].bgColor = "#ffffff";
                                console.log('2');
                                this.errors.push('2');
                            }
                            else if (this.$refs.tr[j].cells[i].innerText > this.$refs.tr[j].cells[i + 1].innerText) {
                                this.$refs.tr[j].cells[i + 1].bgColor = "#dbfee1";
                                console.log(this.$refs.tr[j].cells[i + 1].innerText); //это выводит в браузер, см. на картинке
                            }
                            else if (this.$refs.tr[j].cells[i].innerText === this.$refs.tr[j].cells[i + 1].innerText) {
                                this.$refs.tr[j].cells[i + 1].bgColor = "#fcffce";
                            }
                            else {
                                this.$refs.tr[j].cells[i + 1].bgColor = "#fedbe5";
                            }
                        }
                    }
                });
            }


5f8d40c33f0fe314588124.png5f8d40c945ea5627916369.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
feniksdv, 2020-10-19
@feniksdv

I figured out, I'm inattentive, I compared the wrong columns
, replace it with this
if (this.$refs.tr[j].cells[i].innerText === '')

if (this.$refs.tr[j].cells[i + 1].innerText === '')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question