您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Web开发 >> (vue.js)vue这样做提交可以吗

(vue.js)vue这样做提交可以吗

来源:网络整理     时间:2016/6/4 0:09:24     关键词:vue

关于网友提出的“(vue.js)vue这样做提交可以吗”问题疑问,本网通过在网上对“(vue.js)vue这样做提交可以吗”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:(vue.js)vue这样做提交可以吗
描述:

                this.$http({url: 'http://localhost/wang/index.php/Home/Goods/createGoods', method: 'POST'}
                        ,{"cid": this.cid,"name":this.goodsname,"sort":this.sort,"price":this.price,"desc":this.desc}).then(function (response) {

                            alert("创建成功");

                }, function (response) {
                    // error callback
                });

值写得对不对
"name":this.goodsname
是不是name=goodsname


解决方案1:

如果你问的是对象里是否可以写name= goodsname,那不可以。

你的问题在于vue-resource的用法姿势不对,参数应该这么传:

this.$http({
    url: 'http://localhost/wang/index.php/Home/Goods/createGoods',
    method: 'POST',
    data: {
        cid: this.cid,
        name: this.goodsname,
        sort: this.sort,
        price: this.price,
        desc: this.desc
    }
}).then(function(response) {

    alert('创建成功');

}, function(response) {
    // error callback
});

以上介绍了“(vue.js)vue这样做提交可以吗”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1490345.html

相关图片

相关文章