![](/img/trans.png)
[英]Uncaught ReferenceError when using rl.question node.js
[英]How to display new question when user click button and previous question delete in node.js and pug?
我想做一个简单的测验。 当用户单击按钮时,向他显示新问题。 我不知道该怎么做。
index.js
const express = require('express')
const app = express()
app.set('view engine', 'pug')
app.use(express.urlencoded({ extended: false }))
app.get('/', (req, res) => {
questions = ['firstQuestion', 'secondQuestion']
for (i = 0;i<questions.length;i++) {
res.render('index', {question: question[i]})
}
})
app.listen(3000)
指数.pug
html(lang="en")
head
meta(charset="UTF-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
title Document
body
h1#a
button(onclick='func()')
script.
function func() {
document.getElementById("a").innerHTML = #{question}
}
我不确定哈巴狗是如何工作的,但我有一些一般的想法给你
请记住,您必须将数据保存在某处(userId 到 userQuestionIndex)。这取决于您希望应用程序的安全程度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.