如下所示:
:data-index="index"
:dt="index"
v-on:click="onclick($event,index)"
:data-d ="JSON.stringify( item)"
href="http://www.baidu.com" rel="external nofollow" rel="external nofollow"
data-href="http://www.baidu.com" rel="external nofollow" rel="external nofollow" >
{{ item.text }}
new Vue({
el: '#dt',
data: {
items: [
{ text: '巴士' },
{ text: '快車' },
{ text: '專車' },
{ text: '順風車' },
{ text: '出租車' },
{ text: '代駕' }
]
},
methods: {
onclick:function(event,index){
console.log(event.target)
console.log(index)
event.preventDefault();
event.stopPropagation();
console.log($("#dongtao").attr('id'))
console.log(event.target.parentNode.getAttribute("id"))
console.log('-------------------')
let target = event.target
console.log(target.getAttribute("data-index"));
console.log(target.getAttribute("href"));
console.log(target.getAttribute("data-d"));
document.getElementById('index').value = target.getAttribute("data-index");
}
}
})
// $('#dongtao').on('click', '.nihao', function(){
// console.log($(this).index() +"----"+"dddddddddddddddddd" )
// $(this).hide()
// })
//
// $("input").on('click', function(){
// alert(1111)
// })
以上這篇vue.js2.0點擊獲取自己的屬性和jquery方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。