[Vuejs]-Vue3: is it possible to import a HTML file with components in it to a SFC

0👍

I have now solved the problem myself.

I had to import the components I want to use in the HTML file in app.js and then initialize them with Vue.

import BaseButton from "./components/ui/BaseButton.vue";
app.component("BaseButton", BaseButton);

0👍

Yes it is possible.

You can even import the script and style section:

<template src="./template.html"></template>
<style src="./style.css"></style>
<script src="./script.js"></script>

Read it in the docs.


I don’t know why your code doesn’t work, I tried to create a similar demo and it works fine. See it here on Stackblitz

Leave a comment