search

Home  >  Q&A  >  body text

Methods in a standalone (single file) Vue3 SPA using the Compose API

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.

P粉106711425P粉106711425238 days ago375

reply all(1)I'll reply

  • P粉633733146
  • Cancelreply