1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>通过 CDN 使用 Vue 组合式 API</title> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <style> body { font-family: Arial, Helvetica, sans-serif; }
#app { color: #222; padding: 10px; } </style> </head>
<body> <div id="app"> <span>Message:{{ msg}}</span> <button @click="increment">Click Me</button> </div>
<script> const { createApp, ref } = Vue
const msg = ref('Hello Vue!')
function increment() { msg.value = '你好 Vue!' } const app = createApp({ setup() { return { msg, increment }; } }).mount('#app'); </script> </body>
</html>
|
Author:
Shenhuanjie
Permalink:
http://shenhuanjie.github.io/2024/01/29/eb572e8b9026/
License:
Copyright (c) 2024 CC-BY-NC-4.0 LICENSE
Slogan:
Do you believe in DESTINY?