[Vuejs]-VueJS Loading template component via code?

0👍

The Component imported is not a constructor and it should extends a constructor and to use that you should use Vue.extend()

Vue.extend() is a class inheritance method. Its task is to create a sub-class of Vue and return the constructor.

so instead of this

const error = new dangerAlert({ propsData: { text: "Error message" } });
error.$mount("#error");

make it like this

const DangerAlertExtended= Vue.extend(dangerAlert);
const error = new DangerAlertExtended({ propsData: { text: "Error message" } });
error.$mount("#error");

Leave a comment