在下面的代碼(只是一部分代碼)中,在sss按鍵能觸發(fā)click事件函數(shù)test,但是在nav-item組件上的click事件不能夠觸發(fā)???查閱了一些資料,也一直沒找到答案但是有一個(gè)解決辦法就是在子組件內(nèi)部拋出一個(gè)自定義事件,然后在組件實(shí)例上接收該事件,這樣可以觸發(fā)自定義的事件,但是下面這樣使用click事件不能觸發(fā)就搞不懂,所以想請教一下大家ssssVue.component("nav-item",{props:['itemname'],template:"{{itemname}}",methods:{togg:function(){this.$emit("toggle",this.itemname)},battle:function(){alert(this.itemname);}}});varapp=newVue({el:'#app',data:{nav_item_title:['page1','page2','page3','page4'],current_page:'page1'},computed:{current_component:function(){return"tab-"+this.current_page;}},methods:{activeitem:function(name){this.current_page=name;},test:function(){alert("this");}}});
vue子組件實(shí)例上不能觸發(fā)click事件?
皈依舞
2019-05-13 10:39:33