0👍
Because Vue tries to render the component (on #product_search
) when document
is ready, meaning on every page of your application.
You can add a condition to prevent the null error:
document.addEventListener('DOMContentLoaded', () => {
let element = document.querySelector('#product_search')
if (element) {
document.body.appendChild(document.createElement('app'))
console.log('caricato Vue');
const app = new Vue({
render: h => h(Product)
}).$mount('#product_search')
}
})
- [Vuejs]-Trying to load data in option of dop downl list in vue js , and fetching data from axios api and in mounted function
- [Vuejs]-Vue js applications code throws error (Js Expected)
Source:stackexchange.com