<!DOCTYPE html>
<html lang="en">
<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>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<!--屬性名帶橫線-,則必須加單引號-->
<h1 :style="{ color: 'red','font-weight': 200 }">{{msg}}</h1>
<h1 :style="styleObj1">{{msg}}</h1>
<h1 :style="[styleObj1,styleObj2]">{{msg}}</h1>
</div>
</body>
<script>
//創建一個vue實例
//當我們導入包之後,在瀏覽器的內存中就多了一個vue構造函數
var vm = new Vue({
el: '#app',//表示當前我們new的這個vue實例要控制頁面上的哪個區域
data: { //data屬性中存放的是el中要用到的數據
msg: '我是你爸爸',
flag: true,
styleObj1: { color: 'red','font-weight': 200 },
styleObj2: { 'font-style': 'italic' }
}
});
</script>
</html>