⼩程序开发案例⼆调查问卷第⼀步:主界⾯代码
<view >
<form bindsubmit="submit">
<view>
<text>姓名:</text>
<input name="张三" value = "张三"/>
</view>
<view>
<text>性别:</text>
<radio-group name="gender">
<label ><radio value="0" checked>男</radio></label>
<label ><radio value="1" >⼥</radio></label>
</radio-group>
</view>
<view>
<text>专业技能</text>
<checkbox-group name = "skills">
<label > <checkbox value="html" checked>HTML</checkbox></label>
<label > <checkbox value="css" >CSS</checkbox></label>
<label > <checkbox value="js" >JS</checkbox></label>
<label > <checkbox value="ps" >PS</checkbox></label>
</checkbox-group>
</view>
<view>
<text>您的意见</text>
<textarea name="opinion" value="测试"></textarea>
</view>
<button form-type="submit">提交</button>
</form>
</view>
**第⼆步:css样式修改
`/**index.wxss**/
.container{
margin: 50prx;
}
view{
margin-bottom: 30rpx;
}
input{
width: 600rpx;
margin-top: 10rpx;
border-bottom: 2rpx solid #ccc; }
label{
display: inline;
margin: 8rpx;
}
textarea{
width: 600rpx;
height: 100rpx;
margin-top: 10rpx;
border: 2rpx solid #eee;
}`
第三步:安装环境
先安装node.js写文章的小程序
进⼊官⽹安装稳定版本
安装完毕后在同⼀级创建⼀个空⽂件夹 最好都⽤英⽂⽂件夹名
打开新⽂件夹
打开命令提⽰符cmd 地址到新建的⽂件夹
输⼊ npm init -y
再输⼊ npm install express --save
⽤完之后不要关
会创建好如图⼀个⽂件夹 ⼀个json⽂件
然后再这个⽂件夹内创建⼀个index.js⽂件 ⽤记事本打开 输⼊内容
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.json())
//处理POSE请求
app.post('/',(req,res) =>{
console.log(req.body)
res.json(req.body)
})
//监听3000端⼝
app.listen(3000,() =>{
console.log('server running at 127.0.0.1:3000')
})
打开cmd窗⼝
输⼊ nodemon index.js
出现server running at 127.0.0.1:3000即为成功
然后回到⼩程序 点击提交按钮 打开cmd框回车
出现以下图⽰即为成功 项⽬完成

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。