直接看示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<body>

    <style>
        .fontStyle{
            color:red;
            font-weight: bold;

        }
    </style>

    <div id="app">

        <h4>{{title}}</h4>
<hr>

        <p>1.input中value值绑定v-bind:value="web.url"</p>
        <input type="text" v-bind:value="web.url">
<hr>
        <p>2.img中src属性绑定</p>
        <img :src="web.img" alt="" width="100" height="auto">
<hr>
        <p>3.标签class属性绑定</p>
        <p class="fontStyle">这是一个测试</p>
        <p :class="{fontStyle:web.styles}">这是一个测试2</p>
    </div>

    <script type="module">

        import {createApp,reactive} from './vue.esm-browser.js'

        createApp({
            
            setup(){

                let web = reactive({
                    url:'cn.vuejs.org',
                    img:'vue.png',
                    styles:true
                })

                return {
                    title:'vue动态属性绑定bind',
                    web
                }
            }

        }).mount('#app')


    </script>
    
</body>
</html>

课程地址:https://www.bilibili.com/video/BV1nV411Q7RX?p=8&vd_source=ef3d1a56feb9e6a14f1d066d13b1deda

标签: none

评论已关闭