![](/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.