用vscode做一个兼职小程序代码
以下是一个用VSCode编写的兼职小程序代码示例:
// app.js
App({
onLaunch: function () {
// 初始化
}
})
// pages/index/index.js
Page({
data: {
jobs: [
{ id: 1, title: '兼职1', salary: '100元/小时', location: '北京' },
{ id: 2, title: '兼职2', salary: '80元/小时', location: '上海' },
{ id: 3, title: '兼职3', salary: '120元/小时', location: '广州' }
]
},
onLoad: function () {
// 页面加载时执行的操作
},
onJobTap: function (event) {
var jobId = event.currentTarget.dataset.jobId;
// 根据jobId跳转到兼职详情页面
}
})
// pages/index/index.wxml
<view class="container">
<view wx:for="{{jobs}}" wx:key="id" class="job-item" bindtap="onJobTap" data-job-id="{{item.id}}">
<text class="title">{{item.title}}</text>
<text class="salary">{{item.salary}}</text>
<text class="location">{{item.location}}</text>
</view>
</view>
// pages/index/index.wxss
.container {
padding: 20rpx;
}
.job-item {
margin-bottom: 20rpx;
padding: 20rpx;
background-color: #f5f5f5;
border-radius: 10rpx;
}
.title {
font-size: 28rpx;
font-weight: bold;
}
.salary {
font-size: 24rpx;
color: #999;
}
.location {
font-size: 24rpx;
color: #999;
}
以上代码是一个简单的兼职小程序,主要包含一个首页和兼职列表展示,点击兼职列表项可以跳转到兼职详情页面。你可以根据实际需求进行修改和扩展。
原文地址: http://www.cveoy.top/t/topic/iISG 著作权归作者所有。请勿转载和采集!