vue学习笔记-01

粗心大意要不得

在跟着视频进行vue方法练习的时候,发现明明是跟着视频中打的一模一样的例子,控制台就是报错:

Property or method "claaArray" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property

我知道这个错是因为使用的变量,在vue实例初始化的时候不在属性中声明导致的,但是我的代码命名已经声明了,却还是一直报错:

<body>
		<div id="app1">
			<button @click="click()">切换颜色</button>
			<div :class="classObj">动态绑定class</div>
			<div :class="claaArray">数组绑定class</div>
		</div>
	</body>
	<script>
		var vm = new Vue({
			el:"#app1",
			data:{
				active:true,
				classObj:{
					red:false,
					yellow:true,
					igno:true
				},
				classArray:["smallbox","igno"]
			},
			methods:{
				click:function(){
					this.classObj.red = !this.classObj.red;
					this.classObj.yellow = !this.classObj.yellow;
				}
			}
		})
		
		
	</script>

然而,经过仔细查看,尴尬的事情来了:
html中使用的是:claaArray,而我data中声明的是:classArray,-_-,尴尬的一批,我甚至一度怀疑,vue对驼峰命名解析有问题;
就这么一个破问题,让我看了五六分钟。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值