我想获得按钮单击事件的href属性.
<a v-on:click.prevent="func($event)" href="/user/all/2">
<i class="fa fa-edit"></i>
<span>Get Data</span>
</a>
Run Code Online (Sandbox Code Playgroud)
Main.JS文件
new Vue({
el: 'body',
methods: {
func: function (event) {
element = event.target;
console.log(element); // Output : Select span|i|a element
href = element.getAttribute('href');
},
}
});
Run Code Online (Sandbox Code Playgroud)
目标事件不会选择元素.它选择单击的元素.
Vue-Resource发布请求:
this.$http.post(form.action, new FormData(form)).then(function (response) {
FetchResponse.fetch(this, response.data)
})
Run Code Online (Sandbox Code Playgroud)
请求作为内容类型发送:"application/json; charset = utf-8"但PHP Post不能显示任何数据.
设置标题Vue资源:
request.headers.set('Content-Type','');
但请求内容类型:",multipart/form-data; boundary = ---- WebKitFormBoundaryTsrUACAFB1wuhFOR"
在查询开头有一个逗号.
Jquery发布请求:
$.ajax({
url : form.action,
type : 'POST',
data : new FormData(form),
success : function (reqData) {
FetchResponse.fetch(ss, reqData)
},
});
Run Code Online (Sandbox Code Playgroud)
相同的查询与jQuery无缝协作.jQuery Content-Type:"multipart/form-data; boundary = ---- WebKitFormBoundaryTsrUACAFB1wuhFOR"