@feniksdv

Как проверить в VUE innerText на null или ' '?

Привет. Хочу проверить innerText на пустое значение или ноль, но что-то у меня не получается. вот кусок кода.
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
  • Вопрос задан
  • 381 просмотр
Решения вопроса 1
@feniksdv Автор вопроса
Разобрался, невнимателен я, сравнивал не те колонки
это заменить
if (this.$refs.tr[j].cells[i].innerText === '')
на это
if (this.$refs.tr[j].cells[i + 1].innerText === '')
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы