Install vUE through CDN

The setup ()

createApp()

ref

 

<! DOCTYPEhtml>
<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.0</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.0.11/vue.global.prod.js"></script>
</head>
<body>
  <div id="app">
    {{count}}
    <div>
      <button @click="handleAdd">add</button>
      <button @click="handleSub">Reduction of</button>
    </div>
  </div>
  <script>
    let { createApp, ref } = Vue

    createApp({
      setup() {
        let count = ref(0)

        let handleAdd = () = > {
          count.value++
        }

        let handleSub = () = > {
          count.value--
        }

        return {
          count,
          handleAdd,
          handleSub
        }
      }
    }).mount('#app')
  </script>
</body>
</html>
Copy the code