有什么方法可以将一些Component.vue
文件编译成一些 javascript 文件吗?这样编译后的 js 就可以包含在 HTML 中并与 vue CDN 一起使用。
例如,假设我们有一些组件Component.vue
,如下所示
<template>
<div class="demo">{{ msg }}</div>
</template>
<script>
export default {
data() {
return {
msg: "Jatin Garg",
};
},
};
</script>
<style scoped>
.demo {
color: blue;
}
</style>
现在我们要将编译后的 Component.js 包含在下面的 HTML 文件中。
<html lang="en">
<head>
<script src="/path/to/Component.js"></script>
<script src="vue@next"></script>
<body>
<div id="app">
<component></component>
</div>
</body>
<script>
const app = Vue.createApp({});
app.component("component", Component);
app.mount("#app");
</script>
</head>
<body></body>
</html>
我知道一个名为的图书馆vue3-sfc-loader
做类似的事情。而是使用“.js”文件直接获取Component.vue
文件并编译它。基本上,我想.vue
离线编译文件