在Vue中弄湿我的脚:
JS:
predicted_output = ""
.....
@app.route("/", methods=["GET", "POST"])
def index():
......
pred_s = str(prediction)
m = Money(amount=pred_s, currency='EUR')
predicted_output = str(m)
return redirect(url_for("result"))
@app.route("/result")
def result():
return render_template("result.html", the_final_value=predicted_output)
HTML:
<div class="text-out-main">
{{ the_final_value }}
</div>
当我在控制台中操作时:
person = {'Firstname': "christina", 'Lastname': "hidden from stackoverflow", 'Email': "hidden from stackoverflow" ,'Phone':"hidden from stackoverflow"}
parent = {'Firstname': "galina", 'Lastname': "hidden from stackoverflow", 'Email': "hidden from stackoverflow" ,'Phone':"hidden from stackoverflow"}
def personAndParentFirstName():
print(person, parent['Firstname'])
for i in person.values():
if (i == parent['Firstname']):
return True
return False
print("Is parent: "+str(personAndParentFirstName()))
我得到:
document.addEventListener("DOMContentLoaded", function () {
Vue.component('coordinate-form', {
template: `<form><input type="text" v-model:"coord"></input><input type="submit"></input></form>`
});
const app = new Vue({
delimiters: ['${', '}'],
el: '#findcoordinate',
data: {
coord: '000 000'
}
});
console.log(app.coord); -- prints 000 000 in console.
});
答案 0 :(得分:1)
您为app
事件在函数内部定义了DOMContentLoad
,因此在事件外部(也在控制台中)无法访问它。您需要在窗口对象中定义app
变量才能全局访问它:
const app = new Vue({
///...
});
window.app = app;