<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<div v-bind:style='{border:borderStyle,width:widthStyle,height:heightStyle}'></div>
<button v-on:click='handle'>奇幻</button>
<div v-bind:style='objStyles'></div>
<div v-bind:style='[objStyles,overrideStyles]'></div>
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
/* 语法功能 */
//自定义按键修饰符 名字自定义 对应的值必须是event的值
Vue.config.keyCodes.aaa = 65;
var vm = new Vue({
//绑定的标签
el: '#app',
//自定义按键修饰符
data: {
borderStyle: '1px solid blue',
widthStyle: '100px',
heightStyle: '200px',
objStyles: {
border: '1px solid green',
width: '200px',
height: '100px'
},
overrideStyles: {
border: '5px solid orange',
backgroundColor: 'blue'
}
},
methods: {
handle: function() {
this.heightStyle = '100px';
this.objStyles.width = '100px';
}
}
});
</script>
</body>
</html>
总结