1、v-style 动态绑定style
<!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="js/vue.js"></script>
</head>
<body>
<div id ="app">
<p :style="{fontSize:'60px'}">{
{
msg}}</p>
<!-- 样式动态传入 -->
<p :style="{fontSize:f60}">{
{
msg}}</p>
<!-- 另一种方式 -->
<p :style="getclass()">{
{
msg}}</p>
</div>
<script>
const app = Vue.createApp({
data() {
return{
msg:'hello',
f60:'60px'
}
},
methods: {
getclass(){
return {
fontSize:this.f60}
}
}
}).mount('#app');
</script>
</body>
</html>
2、v-on
2-1 v-on基本使用
<!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="js/vue.js"></script>
</head>
<body>
<div id ="app">
<h1>运算结果:{
{
count}}</h1>
<button v-on:click="add">+</button>
<button v-on:click="sub">