批改状态:合格
老师批语:
// 安装 vite 命令,全局安装npm install -g vite

// 创建一个项目npm init vue@latest

npm install

npm run dev

npm run build

<template><p class="red">{{ ouyangke }}</p><input v-model="ouyangke" /></template><script>export default{data () {return {ouyangke : "欧阳克"}},}</script>

<!-- v-bind 语法糖 @,后面是事件--><!-- js的事件都可以绑定,绑定后才能使用vue的方法--><template><div @click="$event => fun()" >按钮</div></template><script>export default{methods : {fun(){alert("弹窗");}},</script>

<template><div v-on:click="fun(1)">按钮</div><button @click="fun(2)">按钮</button></template><script>export default{methods : {fun(e){alert("弹窗");if( e==1 ){this.color = "color: gray";} else if( e==2 ){this.color = "color: lightblue";}}},}</script>

<template><div :style="color">{{ html }}</div><div v-html="html"></div></template><script>export default{data () {return {color : "color: green",html: "<span style='color:red;'>字符串0000</span>",}},</script>

<template><div v-text="html"></div></template><script>export default{data () {return {color : "color: green",html: "<span style='color:red;'>字符串0000</span>",}},</script>

<template><input v-model="ouyangke"><div v-once>{{ ouyangke }}</div></template>// 方法<script>export default{data () {return {ouyangke : "欧阳克111",num : 20,arr : ['欧阳克','灭绝师太'],color : "color: green",html: "<span style='color:red;'>字符串0000</span>",}},}

<template><div @click.stop="one()">事件1<div @click.stop="two()">事件2<div @click.stop="three()">事件3</div></div></div></template><script>export default{methods : {one(){alert(1);},two(){alert(2);},three(){alert(3);},},}</script>

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号