N
N
Nikolai Khoziashev2021-05-07 17:07:29
css
Nikolai Khoziashev, 2021-05-07 17:07:29

How to display a server error in a component?

<template>
  <b-form @submit.prevent="submitForm()">...</b-form>
  <span :v-if='error'>{{ error.message }}</span>
</template>
<script>
  export default {
    data () {
      return {
        error: ''
      }
    },
    methods: {
      async submitForm () {
        try {} catch (err) {
        this.error = err;
        }
      }
    }
  }
</script>


How do I output error.message to span without connecting second variable with true/false response for if

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dymok, 2018-10-20
@NeTLeaDeR

replace last-child with last-of-type

A
AngReload, 2018-10-20
@AngReload

Because the last one is a div.
In general, according to the rules, only li can be in ul. The validator on the div swears.
https://validator.w3.org/

D
drawnofmymind, 2021-05-07
@The_Last_Dot

<span v-if='error'>{{ error.message }}</span>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question