node.js - Node Pug:使用变量时表单标签的动作属性无法正常工作
问题描述
我有一个 index.pug 页面,它是:
head
title My Title
body
form(method="GET", action='/#{redirect_url}')
button(type='submit') run foo
在我的 app.js 中,我有:
app.get('/', (req, res) => {
res.render('index', {
redirect_url: '/foo'
});
});
app.get('/foo', (req, res) => {
res.status(200).send('Foo triggered');
});
我被重定向到 http://localhost:3000/?#{redirect_url}。
我想重定向到 http://localhost:3000/redirect_url?
当我不使用变量时它工作正常。
我附上了截图供参考。
解决方案
尝试
action=`${baseRoute}/${redirect_url}`
推荐阅读
- bash - 回车被添加到 Azure CLI -o tsv 输出 - 400 客户端错误:对 url 的错误请求
- node.js - 如何将树莓派用作多外围设备
- java - 如何处理空队列参数并在 JUnit 5 中对其进行测试
- php - 按索引获取斐波那契数 - PHP
- javascript - Yii2:HTML 选择仅显示 1 行
- html - 如何使html正文中的div远离其他两个div
- c++ - 使用 CMake 对我自己的库的未定义引用
- kubernetes - 在 WSL2 上安装 Istio 失败并显示 pod 的“FailedMount”
- android - java.lang.ClassNotFoundException: android.os.storage.IMountService
- python - 我有一个要排序的列表列表,例如