axios post可通过flask和vuejs提供多种数据
我所要做的就是从我的web用户输入中获取axios post可通过flask和vuejs提供多种数据,flask,vue.js,axios,Flask,Vue.js,Axios,我所要做的就是从我的web用户输入中获取context\u答案和treatment\u答案,并将其放在烧瓶上。(我对此很陌生,很抱歉,我对自己正在做的事情模糊不清) 我能够通过以下方式得到上下文的答案: `methods: { handleSubmit() { axios.post("/submit_survey", this.context_answers) } }` 在烧瓶上 `@app.route("/submit_survey",
context\u答案
和treatment\u答案
,并将其放在烧瓶上。(我对此很陌生,很抱歉,我对自己正在做的事情模糊不清)
我能够通过以下方式得到上下文的答案:
`methods: {
handleSubmit() {
axios.post("/submit_survey", this.context_answers)
}
}`
在烧瓶上
`@app.route("/submit_survey", methods=["POST"])
def submit_survey():
context = request.get_json(force=True)
context_df = pd.DataFrame.from_dict(context)`
但是你是如何用同样的axios post方法得到这个答案的?在提交调查中
我要创建具有以下内容的数据帧:
abcdy
1 2 3 4 10
非常感谢你 如果要超过多个参数,可以执行以下操作:
methods: {
handleSubmit() {
axios.post("/submit_survey", {context_answers: this.context_answers,
treatments_answers: this.treatments_answers})
.then(
(response) => { console.log(response) },
(error) => { console.log(error) }
)
}
}
或者试试这个:
methods: {
handleSubmit() {
axios.post("/submit_survey", {context_answers: this.context_answers,
treatments_answers: this.treatments_answers})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
});
}
不清楚你在问什么。可能会显示每段数据的示例(即
context\u answers
和treatments\u answers
)以及您希望收到的数据在您的应用程序中的外观谢谢David。那我以后怎么要求呢?我知道它是超基本的。我的意思是,当我只有一个context\u答案时,我使用context=request.get\u json(force=True)
来提取它并将其转换为数据帧。那么现在我该如何保存这个处理呢?理论上你应该在一个变量中捕获轴子,就像这样:const response=wait axios.post(…
然后做一个console.log的响应,告诉我你看到了什么我编辑了我的答案,看看handleSubmit方法是怎样的,再次创建一个console.log响应,然后告诉我你看到了什么
methods: {
handleSubmit() {
axios.post("/submit_survey", {context_answers: this.context_answers,
treatments_answers: this.treatments_answers})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
});
}