programing

마운트된 Vue 인스턴스의 속성을 업데이트하는 방법

prostudy 2022. 6. 30. 22:54
반응형

마운트된 Vue 인스턴스의 속성을 업데이트하는 방법

수동으로 마운트된 Vue 인스턴스의 속성을 여러 DOM 요소(이 경우 맵박스 마커)에 바인딩합니다.

  const makerContent = Vue.extend(Marker)

  features.forEach(function(feature, index) {
    var parent = document.createElement('div')
        parent.classList.add("mapboxgl-marker")
    var child = document.createElement('div')
        child.classList.add("marker")
    parent.appendChild(child)
     const marker = new mapboxgl.Marker(parent)
     .setLngLat(feature.geometry.coordinates)
     .addTo(self.map)

    new makerContent({
      store: store,
      propsData: {
        feature: feature, 
      }
    }).$mount(child); 
  })

스토어 변경(예:feature.geometry.coordinates)는 새로고침 없이 Marker 컴포넌트에서 변경을 트리거하지 않습니다.

어떻게 바인드 할 수 있을까요?features마커가 데이터 변경에 반응하는 경우?아마도 의 올바른 사용은 아닐 것이다.propsData공유 Vuex 스토어 모듈?Vue가 현재 지원하지 않는 ES6 맵 상태의 변화를 추적해야 할 것 같습니다.

우리 엄마 좀 봐.GitHub의 vue 컴포넌트

언급URL : https://stackoverflow.com/questions/47000191/how-to-update-properties-of-mounted-vue-instance

반응형