如何将参数从flask传递到vue.js,并将其分配给vue.js变量。在下面的示例中,我尝试将变量d传递给vue.js。并将其值分配给vue中的point变量。这样做的正确方法是什么,因为每次我遇到错误时,都会出现这种情况。
烧瓶代码
from flask import Flask, Response, jsonify, request,render_template,
import os
app = Flask(__name__)
@app.route("/")
def home():
d = 23
return render_template("index.html")
if __name__=="__main__":
app.secret_key=os.urandom(12)
app.run(debug=True,host='0.0.0.0',port=5000)
VUE代码
var app = new Vue({
el: "#app",
data: {
message: "Some message",
title_variable: "sasasaas!",
show: true,
chores: [
{ text: "aaaaaaaaa" },
{ text: "bbbbbbbb!" },
{ text: "c" }
],
point: {{variable d from flask}}
},
methods: {
hendlerfunction: function() {
this.point = this.point + ".";
}
}
})