<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
<style type="text/css">
.cres{
color: red;
}
.bg{
background-color: #000;
}
.gree{
color: green;
}
.bgn{
background-color: rgb(48, 39, 170);
}
.font{
font-family: "楷体";
}
</style>
</head>
<body>
<div id="root"></div>
<script text="text/javascript">
const app = Vue.createApp({
data() {
return {
message: 'Hello!',
classString: "cres",
classObj: {bg:true,gree:true},
classArray: ["font", "bgn", "cres", {gree:true}],
styleString: '',
styleObj: {
with: '200px',
height: "50px",
backgroundColor: "#789543",
color: 'red'
}
}
},
template: `
<div :class="classString">MVC</div>
<div :class="classObj">啊啦啦啦</div>
<div :class="classArray">啊啦啦啦</div>
<hr />
<div :style="styleString">{{message}}</div>
<div :style="styleObj">{{message}}</div>
<hr />
<demo1 :class="classArray"></demo1>
<hr />
<demo2 :class="classString"></demo2>
`
});
app.component('demo1', {
template: `
<div class="class">我是Demo1</div>
`
})
app.component('demo2', {
template: `
<div>我是Demo2 没class</div>
<div :class="$attrs.class">我是Demo2 有class</div>
`
})
app.mount("#root")
</script>
</body>
</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)