html:
<div id="page">
<button v-for="list in lists" v-on:click="clickEvent">{{list.page}}</button>
</div>
js:
new Vue({
el:'#page',
data:{
lists:[
{page:1},
{page:2},
{page:3},
{page:4}
]
},
methods:{
clickEvent:function () {
url = '<?php echo Yii::$app->urlManager->createUrl("/collect-data-copy/result")?>';
console.log(this);
$.post(url,{page:$(this).text()},function (data) {
console(data);
},'json');
}
}
});
现在想把被点击的button
的值传给后台,应该怎么弄?page:$(this).text()
这个要如何该?
传入到你的方法里面就行,
html:
js:
然后在传入post请求即可
手机上码的字,哈哈?