[英]Why a function is not calling by using v-on click in vue js?
My code is 我的代码是
var div = "<div class=\"liveContent\" id=\""+this.id+"\" refid=\""+refresh+"\" v-onclick=\"showWindow(this)\"><table><tr><td style=\"padding-left:10px;\"><b>"+this.animal+"</b><br>"+this.time+"<br>"+this.username+"</td></tr></table></div>";
$("#liveScroll").prepend(div);
And I have a function in methods as 我在方法中有一个功能
methods: {
showWindow: function(e){
alert(true);
}
},
When I click showWindow is not calling. 当我单击showWindow时没有调用。
My html code is 我的html代码是
<div id="liveScroll" class="liveScroll"></div>
Please help me to have a solution. 请帮我解决。 Using this I am able to display the data but when I click on data nothing happens
使用这个我可以显示数据,但是当我单击数据时什么也没有发生
var div = "<div class=\"liveContent\" id=\""+this.id+"\" refid=\""+refresh+"\" v-onclick=\"showWindow(this)\"><table><tr><td style=\"padding-left:10px;\"><b>"+this.animal+"</b><br>"+this.time+"<br>"+this.username+"</td></tr></table></div>";
Your above code have mistake : 您上面的代码有错误:
it should not v-onclick=\\"showWindow(this)\\"
它不应
v-onclick=\\"showWindow(this)\\"
instead : 相反:
missing ( : ) colon after v-on
v-on
后缺少(:)冒号
v-on:click=\\"showWindow(this)\\"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.