1.通过一个点击切换的案例来理解
<div id="root">
<h2>今天天气很{
{info}}</h2>
<button @click="changeWeather">切换天气</button>
<!--绑定事件的时候 @xxx=yyy yyy可以写一些简单的语句 -->
<!-- <button @click="isHot=!isHot">切换天气</button> -->
</div>
<script>
Vue.config.productionTip = false // 以阻止 vue 在启动时生成生产提示
new Vue({
el: '#root',
data: {
isHot: true
},
computed: {
info() {
return this.isHot ? '凉爽' : '炎热'
}
},
methods: {