I write a (amateur) Vue3 application (*) by bootstrapping the project content and then building it for deployment. good results.
I need to create a standalone single HTML page that can be loaded directly in the browser. I did this a few years ago when I started using Vue (during the v1 → v2 transition) and I immediately found the right documentation.
I can't find similar Vue3 and Composition APIs.
What is a frame page that will display the value of a reactive variable{{hello}} (I will put this in the context of a full build application in <script setup> Definition)
This is how I used to do it (I hope I did it right)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://unpkg.com/vue@2"></script>
</head>
<body>
<div id="app">
{{hello}}
</div>
<script>
// this is how I used to do it in Vue2 if I remember correctly
new Vue({
el: '#app',
data: {
hello: "bonjour!"
}
// methods, watch, computed, mounted, ...
})
</script>
</body>
</html>
(*) I actually use the Quasar framework, but that doesn't change the core of my problem.
According to the official documentation, you cannot use a CDN to use script settings 一>:
But you can use the settings hook in the page script like this:
const { createApp, ref } = Vue; const App = { setup() { const hello = ref('Bonjour') return { hello } } } const app = createApp(App) app.mount('#app')