为什么 laravel vue js this.form.post(url) 自动转换为 get 方法



Vue.js get方法而不是post方法正在工作。但是在本地主机中,它工作得很好。仅在我将项目上传到服务器时遇到此问题

export default {
    data(){
        return {
            form: new Form({
                company_name : '',
                address : '',
                contact_name : '',
                number : '',
                keyword_or_comment : '',
                attachment : ''
            })
        }
    },
    methods: {
        createPhoneBook(){
            this.$Progress.start();
            const url = `${API_URL}/api/apiurl/`;
            this.form.post(url)
            .then(() => {
                toast.fire({
                    type: 'success',
                    title: 'Phone book added successfully'
                })
                this.$Progress.finish();
            })
            .catch(() => {
                this.$Progress.fail()
            })
        }
    },
    created() {
    }
}

任何人都可以帮助我,提前谢谢。

我建议你使用 axios Ajax 请求。 强烈建议 Vue js 这样做。

喜欢:

axios.post(location.pathname, { body: this.body })
            .catch(error => {
                flash(error.response.data, "danger");
            })
            .then(({ data }) => {
                this.body = "";
            });

最新更新