天天看点

vue data和methods可以重名嘛?

答案是不可以的,重名会报错

<div id="chongming">
	    {{testname}}
	    <button v-on:click='dianji'>点击</button>
	</div>
           
new Vue({
	    el:'#chongming',
	    data:{
	        testname:'这是转换信息你知道么?'
	    },
	    methods:{
	        testname:function(){
	            console.log(123);
	        },
	        dianji:function(){
	            this.testname = this.testname.split('').reverse().join('');
	            this.testname();
	        }
	    }
	});
           
vue data和methods可以重名嘛?