@eldenhard2

Как передать значение переменной между двумя компонентами VUE?

В родительском компоненте я получаю данные об ID пользователя, в дочернем я вызываю(модальное окно) фукнцию которая должна получить этот ID, и с этим условием получить ответ от сервера, но не выходит через props никак это осуществить
Мне необходимо передать переменную emplyee
ДОЧЕРНИЙ ЭЛЕМЕНТ(МОДАЛЬНОЕ ОКНО)
    data() {
        return {
            answer1: null,
            answer2: null,
            answer3: null,
            answer4: null,
            answer5: null,
            answer6: null,
            emplyee: '',
            loader: false,
            answer: ''
        }
    },

    props: ['CreatedReport'],
    methods: {
        closeCurrentReport() {
            this.$emit('close')
        },

    },

    mounted() {

        // this.loader = true

        api.getLastDataReports(this.emplyee).then(response => {
            this.answer1 = response.data.attrib1
            this.answer2 = response.data.attrib2
            this.answer3 = response.data.attrib3
            this.answer4 = response.data.attrib4
            this.answer5 = response.data.attrib5
            this.answer6 = response.data.attrib6
          
            this.loader = false

        }).catch(error => {
            this.loader = false
        })
    }


РОДИТЕЛЬСКИЙ
 props: ['emplyee'],
 watch: {
    emplyee() {
      console.log("метод watch");
      this.loader = true;
      api
        .getLastDataReports(this.emplyee)
        .then((response) => {
          if (response.data == "404") {
            this.aboutThisReport = false;
            this.loader = false;
          } else {
            this.aboutThisReport = true;
            this.currentUserReport = response.data;
            this.loader = false;
          }
        })
        .catch((error) => {
          (this.loader = false),
            (notifyHead = "Ошибка"),
            (notifyMessage = "Данные не получены"),
            (this.notifyClass = "wrapper-error");
          this.showNotify = true;
          setTimeout(this.closeNotification, 1500);
          showNotify = true;
        });
    },
  • Вопрос задан
  • 47 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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