Mandatory binding style property

1, Case 1

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>强制绑定style属性</title>
</head>

<body>
    <div id="app">
        <!--style="color: blue; font-size: 50px;"-->
        <p :style="{color:'blue',fontSize:myFontSize+'px'}">pppppppppppppppppp</p>
        <!--color: red; font-size: 35px;-->
        <p :style="myStyle">pppppppppppppppppp</p>
    </div>
    <script src="../js/vue.js" type="text/javascript"></script>
    <script>
        const vm = new Vue({
            el: "#app",
            data: {
                myFontSize: 50,
                myStyle: {
                    color: "red",
                    fontSize: "35px"
                }
            }
        });
    </script>
</body>

</html>

 

Guess you like

Origin www.cnblogs.com/liuyang-520/p/12450895.html