經過cdn安裝vuehtml
setup()vue
createApp()ajax
refapp
<!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.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">加</button> <button @click="handleSub">減</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>