如何将变量发送到JavaScript?

发布于 2024-09-12 03:19:42 字数 52 浏览 3 评论 0原文

我将一个元组作为我的变量发送给 javascript。但我找不到办法。我正在使用瓶子框架。

I am sending a tuple as my variable to javascript. But i could not find a way. I am using bottle framework.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

祁梦 2024-09-19 03:19:42

将其编码为 JSON。它将转换为 JavaScript 数组。

Encode it into JSON. It'll convert to a javascript array.

断舍离 2024-09-19 03:19:42

添加到 @Oil 观点的相关提示,Bottle 默认返回 JSON,您返回一个字典:

@route('/resource.json')
def resource_json():
    response = dict(
        data=('tuple', 'of', 'things'))
return response

请参阅 http://bottle.paws.de/page/docs#output-casting

A related tip to add to @Oil's point, Bottle returns JSON by default of you return a dict:

@route('/resource.json')
def resource_json():
    response = dict(
        data=('tuple', 'of', 'things'))
return response

See http://bottle.paws.de/page/docs#output-casting

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文