欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Vue style行内样式绑定

程序员文章站 2022-03-03 09:19:53
...
<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <style>

    </style>

</head>

<body>
    <!-- V -->
    <div id="app">
        <!-- <h1 style="color:red;font-size:30px">style行内样式绑定</h1> -->
        <h1 :style="{'color':'red','font-size':'30px'}">style行内样式绑定</h1>
        <h1 :style="style1">style行内样式绑定</h1>
        <h1 :style="[style1,style2]">style行内样式绑定</h1>
    </div>

    <script src="./script/vue.js"></script>
    <script>

        //创建Vue实例
        //VM
        var vm = new Vue({
            el: "#app",
            //M
            data: {
                style1: { 'color': 'blue', 'font-size': '30px' },
                style2: { 'font-style': 'italic' },
            },
            methods: {

            },
        })

    </script>

</body>

</html>