1

I was trying to replicate this question with a MCVE, but I was not able to use the Composition API in a <script> tag in index.html.

This is my index.html:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Vue3 script</title>
</head>

<body>
  <div id="app">
  </div>
  <script src="https://unpkg.com/vue@next/dist/vue.global.js"></script>
  <script type="module">
    const app = Vue.createApp({
      el: "#app",
      setup() {
        console.log("foo")
      }
    })
  </script>
</body>

</html>

The console only outputs this:

You are running a development build of Vue.
Make sure to use the production build (*.prod.js) when deploying for production.
GET http://127.0.0.1:5500/favicon.ico [HTTP/1.1 404 Not Found 0ms]
0

1 Answer 1

2

Call .mount(elementId) at the end to make it work

const app = Vue.createApp({
      setup() {
        console.log("foo")
      }
    })
    
app.mount("#app")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.