1234567891011121314151617181920212223242526272829303132333435363738 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>模板</title>
- <!-- 引入文件 -->
- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
- </head>
- <body>
- <div id="app">
- <!-- number -->
- <h3 v-if="number==1" > 好好学习 </h3>
- <h2 v-else > 天天向上 </h2>
- <h3 v-show="number == 1" > 好好学习 </h3>
- <h2 v-show="number != 1" > 天天向上 </h2>
- <button @click="changeBut">改变</button>
- </div>
- </body>
- <script>
- const { createApp, ref } = Vue;
- createApp({
- setup() {
- let number = ref(1);
- function changeBut(){
- number.value = 2;
- }
- return {
- number,changeBut
- };
- }
- }).mount('#app'); //createApp创建对象 挂在到app
- </script>
- </html>
|