准备学 ruby 的前端,还在下 ubuntu。先随便写写
// Create a program that will ask the users name and username, age. have it tell them the information back, in the format
const fs = require('fs')
const readline = require('readline')
let name, age, username, text
let rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
function puts(str, callback) {
rl.question(str + '\n', (answer) => {
callback(answer)
})
}
puts('your name?', (answer) => {
name = answer
puts('your age?', (answer) => {
age = answer
puts('your username?', (answer) => {
username = answer
text = ` Your name is ${name}\n You are ${age} old \n Your username is ${username}`
fs.writeFile('./test.txt', text, function (err) {
if (err) {
throw err;
}
console.log(text)
rl.close()
})
})
})
})
rl.on("close", () => {
process.exit(0)
})
这种一般都是自己写吧,需求不复杂的话其实就是一个特殊一点的表单。控件用 ui 框架里的就好了