Vue is simply manipulate html with javascript.In basic you create a vue object and You mount that object on a div with an id.I wanted to test that i create a .vue file and import this .vue file to a js file and mount it on a div. But it fails. This project is just for trying. This is my project schema.
App.vue content :
<template>
<h1>{{ msg }}</h1>
<h1>.Vue file</h1>
</template>
<script>
export default{
name: 'App',
data(){
return{
msg: 'VUE JS 3'
}
}
}
</script>
app.js content :
import App from './App.vue';
const app = Vue.createApp(App);
app.mount('#app');
index.html content :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue Basics</title>
<link
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/[email protected]/dist/vue.global.js" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
when i add type=”module” to script tag of app.js output is :
when i change type=”module” to type=”application/octet-stream”, there is no error in console but nothing on web page.
I think i can not import a .vue file or .vue file is not working when i import it but why?