小编Ker*_*DER的帖子

VueJS读取Dom属性

我想获得按钮单击事件的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)

目标事件不会选择元素.它选择单击的元素.

javascript vue.js vue-resource vue-component

5
推荐指数
2
解决办法
2万
查看次数

Vue资源发布请求内容类型

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"

问题:https: //github.com/vuejs/vue-resource/issues/398

php laravel vue.js vue-resource vue-component

5
推荐指数
1
解决办法
5748
查看次数

标签 统计

vue-component ×2

vue-resource ×2

vue.js ×2

javascript ×1

laravel ×1

php ×1