1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <!-- 引入Vue 3 CDN -->
- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
- <style>
- .textColor {
- color: blue; /* 或者任何你想要的颜色 */
- }
- </style>
- </head>
- <body>
- <div id="app">
- <!-- :value -->
- <h3>Value="baidu.com"</h3>
- <input type="text" :value="web.url">
- <h3>v-bind:Value="baidu.com"</h3>
- <input type="text" v-bind:value="web.url">
- <h3>:Value="baidu.com"</h3>
- <input type="text" :value="web.url">
- <!-- :src -->
- <h3>src="web.jpg":</h3>
- <img src="123.jpg">
- <h3>:src="web.img":</h3>
- <img :src="web.img">
- <!-- :class -->
- <h3>class="textColor"</h3>
- <b class="textColor">邓瑞编程</b>
- <h3>:class="'textColor': web.fontstatus"</h3>
- <b :class="{'textColor': web.fontstatus}">邓瑞编程</b>
- </div>
- <script>
- const { createApp, reactive } = Vue;
- createApp({
- setup() {
- // 定义响应式数据
- const web = reactive({
- url: "www.baidu.com",
- img: "123.jpg",
- fontstatus: true
- });
- return {
- web,
- };
- }
- }).mount('#app'); // 挂载到DOM元素上
- </script>
- </body>
- </html>
|