Answer the question
In order to leave comments, you need to log in
How to correctly connect vue component to the page?
tell me how to correctly connect the component script only on the required page? There is an index.js entry point in webpack, if I include a vue component in it everything works fine. But at the same time, this script is connected to all pages, which I need to avoid.
When making this connection into a separate js file
import { createApp } from "vue";
import App from "./App.vue";
import store from "./vuex/store.js";
createApp(App)
.use(store)
.mount("#app-cart");
Failed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../"
- var pageName = "Front"
doctype html
html(lang="ru")
block head
......
body
.......
include components/header
include components/footer
block header
+header-var
block title
block content
.wrap
.content
........
block footer
+footer-var
include components/popups
......
script(type="module", src="assets/js/cart-vue.js")
Answer the question
In order to leave comments, you need to log in
The script of which lies in assets and is simply inlined in html - it is not compiled by webpack and is included as is. Obviously, nothing will work.
You need to add an extra entry
for webpack to get it to compile the result. Or make a separate webpack project for this script.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question