• 前端开发流程与技术选型


    目录

    一、简介

    二、前端职责

    三、开发步骤

    四、技术选型

    五、页面展示


    一、简介

    做一个网站时,能看到的一切都是前端程序员的工作,负责网页或者app的结构、样式、用户操作网站时的事件逻辑(比如点击一个按钮)。

    二、前端职责

    前端程序员工作职责:

            ①和产品经理沟通需求,按照产品经理要求完成相应功能。

            ②和UI设计师沟通样式,按照UI设计图还原样式。

            ③和后端协作,对接后端api接口进行调试,进行登录验证,以及根据用户操作数据的增删改查。

    三、开发步骤

    从0-1开发一个前端项目,我们需要经历11个步骤。

    具体步骤有:

    其中有几个步骤详细说明一下:

    四、技术选型

    前端目前主要使用的技术有:

            ①前端运行环境:Node.js(npm是Node.js的官方包管理工具)

            ②框架:Vue、React、Uniapp、微信原生小程序框架、bootstrap、Angular等

            ③结构:HTML

            ④样式:CSS、CSS预处理器(Scss、Less、Stylus)

            ⑤逻辑:JavaScript(ECMAScript、Bom、Dom)

            ⑥代码分布式存储工具:Git、远程库(Gitee、Github、阿里云、腾讯云)

            ⑦打包工具:Webpack、Vite

            ⑧调试工具:Chrome DevTools(谷歌浏览器调试工具,可以调试手机端电脑端)、微信开发者工具(用来调试微信小程序、企业微信小程序、小游戏)

            ⑨兼容性:电脑端(各种尺寸的电脑、各种厂家的浏览器的样式和方法)、手机端(Android、iOS、Harmony等手机系统的差异) 、响应式开发

            ⑩浏览器:谷歌(google chrome)、360、火狐(Firefox)、Microsoft Edge、Safari

    五、页面展示

    这是一个Web前端页面:

    使用Node.js环境、vue框架、Less(CSS预处理器)、谷歌浏览器展示。

    这是一个微信小程序页面:

    使用Node.js环境、Uniapp框架(vue3版本)、Scss(CSS预处理器)、微信开发者工具展示。

    这是相应前端代码:

    1. <script setup>
    2. import { reactive, toRefs, computed, onMounted, ref } from 'vue';
    3. import { useStore } from 'vuex';
    4. import { onLoad, onHide } from '@dcloudio/uni-app';
    5. const store = useStore();
    6. const state = reactive({
    7. week: ['日', '一', '二', '三', '四', '五', '六'],
    8. currentYear: '',
    9. currentMonth: '',
    10. currentToday: '',
    11. // 0周日,1周一
    12. monthFirstDayCurrentWeek: '',
    13. monthFinallyDayCurrentWeek: '',
    14. //currentMonthAllDate里面是一个一个的对象 ,对象属性number当前日期,isPlan当天是否有计划,month是否是当前月里面的日期,因为要显示不同的样式。还以根据需要在添加其他属性。
    15. currentMonthAllDate: [],
    16. lastMonthDateNumber: 0,
    17. nextMonthDateNumber: 0,
    18. // showMonthOrWeek为true,代表显示周,false显示月
    19. showMonthOrWeek: true,
    20. currentTodayDate: '',
    21. initialX: '',
    22. currentMonthNum: ''
    23. });
    24. const {
    25. currentMonthNum,
    26. initialX,
    27. currentTodayDate,
    28. showMonthOrWeek,
    29. lastMonthDateNumber,
    30. nextMonthDateNumber,
    31. currentMonthAllDate,
    32. week,
    33. currentMonth,
    34. currentYear,
    35. currentToday,
    36. monthFirstDayCurrentWeek,
    37. monthFinallyDayCurrentWeek
    38. } = toRefs(state);
    39. // 今天凌晨
    40. state.currentTodayDate = new Date(new Date(new Date().toLocaleDateString()).getTime());
    41. /**
    42. * 记录手指触碰初始位置
    43. */
    44. const handleTouchStart = (event) => {
    45. state.initialX = event.changedTouches[0].clientX;
    46. };
    47. /**
    48. * 左右滑动事件
    49. */
    50. const handleTouchEnd = (event, index) => {
    51. const currentX = event.changedTouches[0].clientX;
    52. if (currentX - state.initialX > 20) {
    53. //往右滑动,上个月
    54. state.currentTodayDate = state.currentMonth == 1 ? new Date(`${state.currentYear - 1}/12/1`) : new Date(`${state.currentYear}/${state.currentMonthNum - 1}/1`);
    55. getAllDatesOfCurrentMonth(state.currentTodayDate);
    56. return;
    57. }
    58. if (state.initialX - currentX > 20) {
    59. // 往左滑动,下个月
    60. state.currentTodayDate = state.currentMonth == 12 ? new Date(`${state.currentYear + 1}/1/1`) : new Date(`${state.currentYear}/${state.currentMonthNum + 1}/1`);
    61. getAllDatesOfCurrentMonth(state.currentTodayDate);
    62. return;
    63. }
    64. };
    65. /**
    66. * 选中哪天
    67. */
    68. const selectedDate = (date) => {
    69. state.currentTodayDate = date;
    70. getAllDatesOfCurrentMonth(state.currentTodayDate);
    71. // 下面去后端请求计划数据,并展示
    72. };
    73. /**
    74. * 切换显示周还是月
    75. */
    76. const changeShowWeekOrMonth = () => {
    77. state.showMonthOrWeek = !state.showMonthOrWeek;
    78. getAllDatesOfCurrentMonth(state.currentTodayDate);
    79. };
    80. /**
    81. * 得到当前月份/当前周的所有日期,dateData某天日期
    82. */
    83. const getAllDatesOfCurrentMonth = (dateData) => {
    84. state.currentMonthAllDate = [];
    85. const today = new Date(dateData);
    86. state.currentToday = today;
    87. state.currentYear = today.getFullYear();
    88. state.currentMonthNum = today.getMonth() + 1;
    89. if (today.getMonth() + 1 < 10) {
    90. state.currentMonth = '0' + (today.getMonth() + 1);
    91. } else {
    92. state.currentMonth = today.getMonth() + 1;
    93. }
    94. // 上个月总天数
    95. const lastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1);
    96. state.lastMonthDateNumber = new Date(lastMonth.getFullYear(), lastMonth.getMonth() + 1, 0).getDate();
    97. // 下个月总天数
    98. const nextMonth = new Date(today.getFullYear(), today.getMonth() + 1, 1);
    99. state.nextMonthDateNumber = new Date(nextMonth.getFullYear(), nextMonth.getMonth() + 1, 0).getDate();
    100. const dates = [];
    101. // 用if,else判断显示周还是月
    102. if (state.showMonthOrWeek) {
    103. // 显示当前选中日期所在周
    104. let day = today.getDay();
    105. let startDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() - day);
    106. let endDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() - day + 6);
    107. let currentMonthTwo = today.getMonth() + 1;
    108. for (let i = startDate; i <= endDate; ) {
    109. let monthFlag = '';
    110. if (new Date(i).getMonth() + 1 == currentMonthTwo) {
    111. monthFlag = 'current';
    112. } else if (new Date(i).getMonth() + 1 > currentMonthTwo) {
    113. monthFlag = 'last';
    114. } else {
    115. monthFlag = 'next';
    116. }
    117. dates.push(new Date(i));
    118. state.currentMonthAllDate.push({ number: i.getDate(), month: monthFlag, date: new Date(i) });
    119. i.setDate(i.getDate() + 1);
    120. }
    121. } else {
    122. // 显示当前选中日期所在月
    123. const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
    124. const lastDayOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
    125. state.monthFirstDayCurrentWeek = firstDayOfMonth.getDay();
    126. state.monthFinallyDayCurrentWeek = lastDayOfMonth.getDay();
    127. // 补充上个月显示在本月的天数,例如5.1是周三,则周日周一周二显示上个月
    128. if (state.monthFirstDayCurrentWeek != 0) {
    129. // 判断上个月是不是上一年
    130. let isLastYearNumber = lastMonth.getMonth() + 1 == 12 ? 1 : 0;
    131. for (let i = 0; i < state.monthFirstDayCurrentWeek; i++) {
    132. state.currentMonthAllDate.push({
    133. number: state.lastMonthDateNumber - state.monthFirstDayCurrentWeek + 1,
    134. month: 'last',
    135. date: `${state.currentYear - isLastYearNumber}/${lastMonth.getMonth() + 1}/${state.lastMonthDateNumber - state.monthFirstDayCurrentWeek + 1}`
    136. });
    137. state.lastMonthDateNumber++;
    138. }
    139. }
    140. for (let i = firstDayOfMonth; i <= lastDayOfMonth; ) {
    141. dates.push(new Date(i));
    142. state.currentMonthAllDate.push({ number: dates.length, month: 'current', date: new Date(i) });
    143. i.setDate(i.getDate() + 1);
    144. }
    145. if (state.monthFinallyDayCurrentWeek != 6) {
    146. // 判断下个月是不是下一年
    147. let yearNumber = nextMonth.getMonth() + 1 == 1 ? 1 : 0;
    148. for (let i = 0; i < 6 - state.monthFinallyDayCurrentWeek; i++) {
    149. state.currentMonthAllDate.push({ number: i + 1, month: 'next', date: `${state.currentYear + yearNumber}/${nextMonth.getMonth() + 1}/${i + 1}` });
    150. }
    151. }
    152. }
    153. return dates;
    154. };
    155. getAllDatesOfCurrentMonth(state.currentTodayDate);
    156. // 可删除,做了几个假数据,假装几天有计划的,isPlan为true代表当天有计划。
    157. state.currentMonthAllDate[2].isPlan = true;
    158. state.currentMonthAllDate[4].isPlan = true;
    159. state.currentMonthAllDate[0].isPlan = true;
    160. script>
    161. <style scoped lang="scss">
    162. .calendarbBox {
    163. width: 735rpx;
    164. margin-left: 7.5rpx;
    165. display: flex;
    166. justify-content: space-around;
    167. flex-wrap: wrap;
    168. .singleDay {
    169. width: 105rpx;
    170. height: 87rpx;
    171. line-height: 87rpx;
    172. color: #333;
    173. font-size: 32rpx;
    174. font-weight: bold;
    175. text-align: center;
    176. position: relative;
    177. .dayText {
    178. position: relative;
    179. z-index: 9;
    180. }
    181. .dayTextA {
    182. position: relative;
    183. z-index: 9;
    184. color: #fff;
    185. font-size: 32rpx;
    186. font-weight: bold;
    187. text-align: center;
    188. }
    189. .dayTextB {
    190. position: relative;
    191. z-index: 9;
    192. color: #e1e1e1;
    193. font-size: 32rpx;
    194. font-weight: bold;
    195. text-align: center;
    196. }
    197. .point {
    198. width: 12rpx;
    199. height: 12rpx;
    200. background-color: #00b498;
    201. position: absolute;
    202. top: 65rpx;
    203. left: 50%;
    204. transform: translate(-50%, 0);
    205. border-radius: 50%;
    206. }
    207. .selectedDayBGColor {
    208. width: 87rpx;
    209. height: 87rpx;
    210. background-color: #00b498;
    211. border-radius: 50%;
    212. position: absolute;
    213. top: 0;
    214. left: 9rpx;
    215. }
    216. .pointA {
    217. width: 12rpx;
    218. height: 12rpx;
    219. background-color: #fff;
    220. position: absolute;
    221. top: 65rpx;
    222. left: 50%;
    223. transform: translate(-50%, 0);
    224. border-radius: 50%;
    225. }
    226. }
    227. }
    228. .transitionTime {
    229. transition: transform 0.5s;
    230. }
    231. .arrowBox {
    232. width: 750rpx;
    233. height: 109rpx;
    234. line-height: 109rpx;
    235. position: relative;
    236. .arrowButtonRegion {
    237. width: 100rpx;
    238. height: 50rpx;
    239. line-height: 50rpx;
    240. @include fsc();
    241. position: absolute;
    242. left: 50%;
    243. top: 50%;
    244. transform: translate(-50%, -50%);
    245. background-color: #00b488;
    246. border-radius: 10rpx;
    247. color: #fff;
    248. font-size: 28rpx;
    249. text-align: center;
    250. }
    251. }
    252. .titleBox {
    253. width: 750rpx;
    254. height: 92rpx;
    255. background-color: #fff;
    256. position: relative;
    257. padding-bottom: 60rpx;
    258. .title {
    259. position: absolute;
    260. left: 30rpx;
    261. top: 25rpx;
    262. color: #333;
    263. font-size: 53rpx;
    264. font-weight: bold;
    265. text-align: left;
    266. }
    267. }
    268. .week {
    269. width: 750rpx;
    270. height: 39rpx;
    271. color: #999;
    272. font-size: 32rpx;
    273. font-weight: bold;
    274. text-align: left;
    275. display: flex;
    276. justify-content: space-around;
    277. margin-left: 7.5rpx;
    278. margin-bottom: 49rpx;
    279. }
    280. style>

  • 相关阅读:
    定时任务调度(crond)
    C++ 使用栈求解中缀、后缀表达式的值
    基于PHP的纺织用品商城系统
    R语言使用df函数生成F分布密度函数数据、使用plot函数可视化F分布密度函数数据(F Distribution)
    redis基础2——key的基础使用、五大数据类型和三大特殊数据类型
    Go实现日志2——支持结构化和hook
    汇川PLC编程软件AutoShop的使用
    C++ | Leetcode C++题解之第191题位1的个数
    机器学习(四)R平方和回归模型的评价
    Matplotlib 主要参数配置
  • 原文地址:https://blog.csdn.net/zxy19931069161/article/details/139836300