programing

파이어폭스에서 Vuejs 이벤트가 작동하지 않음 - Chrome에서는 정상

bestcode 2022. 8. 15. 21:13
반응형

파이어폭스에서 Vuejs 이벤트가 작동하지 않음 - Chrome에서는 정상

나는 vuejs에서 행사가 있다.

methods: {
   filterPeople: function filterPeople() {
      $(event.target).closest('li').addClass('active');
});

Firefox에서 오류가 발생함

TypeError: event is undefined
mounted/<
re/e.prototype.$emit
filterPeople

FF에서 이 기능이 작동하지 않는 이유를 알고 계십니까?

Firefox에는 글로벌 이벤트 개체가 없습니다.

WebKit은 "이벤트"에 글로벌 기호를 사용하는 IE의 오래된 동작을 따르지만 Firefox는 그렇지 않습니다.

단순히 파라미터로 추가합니다.

methods: {
  filterPeople: function filterPeople(event) {
    $(event.target).closest('li').addClass('active');
  }
}

합격해야 합니다.event파라미터로서 다음과 같이 해야 합니다.

methods: {
  filterPeople: function(event) {
    $(event.target).closest('li').addClass('active');
  }
}

메모: 함수 정의에서 이름이 중복되었습니다.

이게 도움이 됐으면 좋겠다.

function filterPeople()에 이벤트를 전달합니다.다음과 같이 합니다.

methods: {
  filterPeople: function filterPeople (e) {
  $(e.target).closest('li').addClass('active');
});

언급URL : https://stackoverflow.com/questions/46120360/vuejs-event-not-working-in-firefox-fine-in-chrome

반응형