source

Django의 Vue 동적 html 형식

factcode 2022. 8. 24. 23:49
반응형

Django의 Vue 동적 html 형식

있습니다FormView이 양식을 모달에 전시하고 싶습니다.그래서 Vue 컴포넌트를 만들고 작성 시 이를 다음과 같이 부릅니다.

created: function(){
    let self = this;
    $.get(window.profileUrls.registration, function (data){  
        $('#registerModal').replaceWith(data);       
        self.$forceUpdate();
    });
}

Django에서 HTML을 폼으로 반환하고 기본 빈 모드를 이 HTML로 바꿉니다. 그러나 강제로 업데이트를 다시 초기화하지 않습니다.v-model기타 바인딩 및 vue는 컴포넌트 데이터를 업데이트하지 않습니다.

GET 요청 후 구성 요소를 수동으로 다시 초기화하는 방법이 있습니까?

https://vuejs.org/v2/guide/components.html#Async-Components

현재 사용하고 있는 솔루션:

Vue.component('async-example', function (resolve, reject) {
  get('backendurl', function (data) {
    // Pass the component definition to the resolve callback
    resolve({
      template: data
    })
  });
})

언급URL : https://stackoverflow.com/questions/42906414/vue-dynamic-html-form-from-django

반응형