• H5页面,上下滑动翻页(整页翻书切换效果)


    使用 H5页面上下滑动翻页 修改

    页面间的切换:整页翻书的切换效果

    demo代码:

    1. html>
    2. <html>
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    6. <meta name="viewport" content="width=750, user-scalable=no">
    7. <meta http-equiv="pragma" content="no-cache">
    8. <meta http-equiv="Cache-Control" content="no-cache">
    9. <meta http-equiv="Expires" content="0">
    10. <meta name="apple-mobile-web-app-capable" content="yes">
    11. <meta name="apple-mobile-web-app-status-bar-style" content="black">
    12. <meta name="format-detection" content="telephone=no">
    13. <meta name="apple-mobile-web-app-title" content="">
    14. <title>整页翻书效果切换-支持PC、移动端上下滑动翻页title>
    15. <style>
    16. *{ margin:0px; padding:0px; box-sizing:border-box; -webkit-tap-highlight-color:rgba(0,0,0,0);}
    17. html{ max-width:750px; margin:0 auto;}
    18. body{ font-family:"PingFangSC-Regular","sans-serif","STHeitiSC-Light","微软雅黑","Microsoft YaHei"; font-size:28px; line-height:1.6; color:#212121;
    19. -webkit-user-select:none; user-select:none;
    20. -webkit-touch-callout:none; touch-callout:none;
    21. }
    22. html , body{ width:100%; height:100%; position:relative; overflow:hidden;}
    23. /***************************/
    24. .page_box{ width:100%; height:100%; position:relative; overflow:hidden;
    25. perspective: 800px;
    26. }
    27. .page_box::before{ /* content: ""; */ width: 50px; height:100%; /* z-index: 1; */ position: absolute; left: 0; top:0;
    28. background-image: -webkit-linear-gradient(180deg , rgb(254,254,254) , rgb(250,250,250) , rgb(242,242,242) , rgb(221,221,221) , rgb(235,235,235) , rgb(245,244,247) , rgb(238,240,242));
    29. }
    30. .page{ width:calc(100% - 40px); height:calc(100% - 50px); position:absolute; left:25px; top:25px; overflow:hidden;
    31. display:flex; flex-direction: column; justify-content:center; align-items:center;
    32. box-shadow: 0 0 10px 0 rgba(0,0,0,.3);
    33. transform-origin: left;
    34. transform: rotateY(-2deg);
    35. }
    36. .page_body.hide{ display:none;}
    37. .page.inTop{
    38. -webkit-animation:ShowTop .8s ease-out both;
    39. animation:ShowTop .8s ease-out both;
    40. }
    41. .page.outTop{
    42. z-index:1;
    43. -webkit-animation:HideTop 1.5s ease-out both;
    44. animation:HideTop 1.5s ease-out both;
    45. }
    46. .page.inDown{
    47. -webkit-animation:ShowDown .8s ease-out both;
    48. animation:ShowDown .8s ease-out both;
    49. }
    50. .page.outDown{
    51. z-index:1;
    52. -webkit-animation:HideDown 1.5s ease-out both;
    53. animation:HideDown 1.5s ease-out both;
    54. }
    55. @-webkit-keyframes ShowTop{
    56. 0%{ -webkit-transform:rotateY(3deg);}
    57. 100%{ -webkit-transform:rotateY(-2deg);}
    58. }
    59. @keyframes ShowTop{
    60. 0%{ transform:rotateY(3deg);}
    61. 100%{ transform:rotateY(-2deg);}
    62. }
    63. @-webkit-keyframes HideTop{
    64. 0%{ -webkit-transform:rotateY(-2deg);}
    65. 100%{ -webkit-transform:rotateY(-130deg);}
    66. }
    67. @keyframes HideTop{
    68. 0%{ transform:rotateY(-2deg);}
    69. 100%{ transform:rotateY(-130deg);}
    70. }
    71. @-webkit-keyframes ShowDown{
    72. 0%{ -webkit-transform:rotateY(3deg);}
    73. 100%{ -webkit-transform:rotateY(-2deg);}
    74. }
    75. @keyframes ShowDown{
    76. 0%{ transform:rotateY(3deg);}
    77. 100%{ transform:rotateY(-2deg);}
    78. }
    79. @-webkit-keyframes HideDown{
    80. 0%{ -webkit-transform:rotateY(-2deg);}
    81. 100%{ -webkit-transform:rotateY(-130deg);}
    82. }
    83. @keyframes HideDown{
    84. 0%{ transform:rotateY(-2deg);}
    85. 100%{ transform:rotateY(-130deg);}
    86. }
    87. .arrow{ width:60px; height:52px; color: #f00; font-size: 36px; position:absolute; left:50%; margin-left: -30px; bottom:0;
    88. -webkit-animation:fadeIn .5s 1s ease-in-out both;
    89. animation:fadeIn .5s 1s ease-in-out both;
    90. }
    91. .arrow.hide{ display:none;}
    92. .arrow div:first-child , .arrow div:last-child{ display: flex; justify-content: center; align-items: center; width:60px; height: 40px; position:absolute; left:0;
    93. -webkit-transform-origin:center top;
    94. transform-origin:center top;
    95. }
    96. .arrow div:first-child{ top:0;
    97. -webkit-animation:arrow .8s .5s ease-in-out infinite alternate;
    98. animation:arrow .8s .5s ease-in-out infinite alternate;
    99. }
    100. .arrow div:last-child{ top:12px;
    101. -webkit-animation:arrow .8s .8s ease-in-out infinite alternate;
    102. animation:arrow .8s .8s ease-in-out infinite alternate;
    103. }
    104. @-webkit-keyframes arrow{
    105. 100%{ -webkit-transform:translateY(-50%); opacity:1;}
    106. 0%{ -webkit-transform:translateY(0); opacity:0;}
    107. }
    108. @keyframes arrow{
    109. 100%{ transform:translateY(-50%); opacity:1;}
    110. 0%{ transform:translateY(0); opacity:0;}
    111. }
    112. /***************************/
    113. @-webkit-keyframes fadeInMinToMax{
    114. 0%{ -webkit-transform:scale(0); opacity:0;}
    115. 100%{ -webkit-transform:scale(1); opacity:1;}
    116. }
    117. @keyframes fadeInMinToMax{
    118. 0%{ transform:scale(0); opacity:0;}
    119. 100%{ transform:scale(1); opacity:1;}
    120. }
    121. .page{ font-size: 40px; background:url(data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wgARCAAkAn8DAREAAhEBAxEB/8QAGwABAQEBAQEBAQAAAAAAAAAAAAUGBAMCAQn/xAAdAQEAAwEBAQEBAQAAAAAAAAAABAUGBwMBAggJ/9oADAMBAAIQAxAAAAH+gH+J/wDWgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA97WJsOoZvEca14At7ij9ZDP8/vABs+u5TL8/vOSingelhF2fWM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Fat1XhzXe90pgtAjVynnd26ptmza4XYc0Gr0a4CC3MPLT69UsLcJbA0/HRogHdl+bfd8m71msFvqHMyrgVMXrKeeXN2AIhH8mw6nV0vK2mVm3YUFZ0zfcsPf+OPhiOkIUG7apYl6zy6m7fM2YT6QEyZ/rpQHkeHZ3JDnOhRdJlQMksnUQ7OumSBiELTezvXPBOeDF3CqfjBfDqNMi6IGvyYxdOXfqOOencXGA4XMQSDIlcyTuBMFgDS/Z2a+5KzLy3VeHNd73SmC2FBT5KUBVnf8AItneBmuScD3njCNlZhMBQyE1L9u6aBMA7/rQH98Ico7yYudY+zixFU7x9nLcQcv7iN01QKOCC93eMbquXSSp1cybol7mlaIZ1sJ2En1uKRWLFgFjkBT1F0jrAREOtBCjDIBEKJTV3XwoX1dOQENVZOONAKR1F3q8gdbgykEAEUQEdIiOVXJ2dCYjIbrLVgBHCpAU9R+eoCBiIRN0OjBH4ZJVYg1iYuolWpvTLlbAQQe3U40ZmGIzOzo4kzDbhLEHk3S8RxGB9hBggahRPIujheEphJFXf//Z) repeat-y; background-size:100%;}
    122. .page1_title{ width:80%; height:100px; line-height:100px; margin: 0 auto; text-align: center; font-size: 50px;
    123. -webkit-animation:fadeInMinToMax .8s .4s ease-out both;
    124. animation:fadeInMinToMax .8s .4s ease-out both;
    125. }
    126. .page1 .scroll_box{ width:80%; height:60vh; margin: 0 auto; overflow-y:auto; -webkit-overflow-scrolling:touch;
    127. -webkit-animation:fadeInMinToMax 1.5s .4s ease-out both;
    128. animation:fadeInMinToMax 1.5s .4s ease-out both;
    129. }
    130. .page2 .scroll_box{ width: 100%; height: 100%; text-align: center; overflow-y: auto; -webkit-overflow-scrolling: touch;}
    131. .page2 .scroll_box > div{ padding: 50px 0 80px 0;}
    132. .page2_body div:nth-child(1) , .page3_body div:nth-child(1){
    133. -webkit-animation:fadeInMinToMax .8s .4s ease-out both;
    134. animation:fadeInMinToMax .8s .4s ease-out both;
    135. }
    136. .page2_body div:nth-child(2) , .page3_body div:nth-child(2){
    137. -webkit-animation:fadeInMinToMax .8s .5s ease-out both;
    138. animation:fadeInMinToMax .8s .5s ease-out both;
    139. }
    140. .page2_body div:nth-child(3) , .page3_body div:nth-child(3){
    141. -webkit-animation:fadeInMinToMax .8s .6s ease-out both;
    142. animation:fadeInMinToMax .8s .6s ease-out both;
    143. }
    144. .page2_body div:nth-child(4) , .page3_body div:nth-child(4){
    145. -webkit-animation:fadeInMinToMax .8s .7s ease-out both;
    146. animation:fadeInMinToMax .8s .7s ease-out both;
    147. }
    148. .page2_body div:nth-child(5) , .page3_body div:nth-child(5){
    149. -webkit-animation:fadeInMinToMax .8s .8s ease-out both;
    150. animation:fadeInMinToMax .8s .8s ease-out both;
    151. }
    152. .page2_body div:nth-child(6) , .page3_body div:nth-child(6){
    153. -webkit-animation:fadeInMinToMax .8s .9s ease-out both;
    154. animation:fadeInMinToMax .8s .9s ease-out both;
    155. }
    156. .page2_body div:nth-child(7) , .page3_body div:nth-child(7){
    157. -webkit-animation:fadeInMinToMax .8s 1s ease-out both;
    158. animation:fadeInMinToMax .8s 1s ease-out both;
    159. }
    160. .page2_body div:nth-child(8) , .page3_body div:nth-child(8){
    161. -webkit-animation:fadeInMinToMax .8s 1.1s ease-out both;
    162. animation:fadeInMinToMax .8s 1.1s ease-out both;
    163. }
    164. .page2_body div:nth-child(9) , .page3_body div:nth-child(9){
    165. -webkit-animation:fadeInMinToMax .8s 1.2s ease-out both;
    166. animation:fadeInMinToMax .8s 1.2s ease-out both;
    167. }
    168. .page2_body div:nth-child(10) , .page3_body div:nth-child(10){
    169. -webkit-animation:fadeInMinToMax .8s 1.3s ease-out both;
    170. animation:fadeInMinToMax .8s 1.3s ease-out both;
    171. }
    172. style>
    173. head>
    174. <body>
    175. <div class="page_box">
    176. <div class="page page1">
    177. <div class="page_body hide page1_body">
    178. <div class="page1_title">标题标题标题标题div>
    179. <div class="scroll_box">
    180. <div>
    181. <p>行内滚动内容行内滚动内容行内滚动内容行内滚行内滚动内容行内滚动内容动内容行p>
    182. <p>行内滚动内容行内滚动内容行内滚动内容行内滚行内滚动内容行内滚动内容动内容行p>
    183. <p>行内滚动内容行内滚动内容行内滚动内容行内行内滚动内容行内滚动内容滚动内容行p>
    184. <p>行内滚动内容行内滚动内容行内滚动内容行内滚动内容行内滚动内容行内滚动内容行p>
    185. <p>行内滚动内容行内滚动内容行内滚动内容行内滚动内容行内滚动内容行内滚动内容行p>
    186. <p>行内滚动内容行内滚动内容行内滚动内容行行内滚动内容行内滚动内容内滚动内容行p>
    187. <p>行内滚动内容行内滚动内容行内滚动内容行内行内滚动内容行内滚动内容滚动内容行p>
    188. <p>行内滚动内容行内滚动内容行内滚动内容行内行内滚动内容行内滚动内容滚动内容行p>
    189. div>
    190. div>
    191. div>
    192. div>
    193. <div class="page page2">
    194. <div class="page_body hide page2_body scroll_box">
    195. <div>
    196. <div>22222222222div>
    197. <div>22222222222div>
    198. <div>22222222222div>
    199. <div>22222222222div>
    200. <div>22222222222div>
    201. <div>22222222222div>
    202. <div>22222222222div>
    203. <div>22222222222div>
    204. <div>22222222222div>
    205. <div>22222222222div>
    206. <div>22222222222div>
    207. <div>22222222222div>
    208. <div>22222222222div>
    209. <div>22222222222div>
    210. <div>22222222222div>
    211. <div>22222222222div>
    212. <div>22222222222div>
    213. <div>22222222222div>
    214. <div>22222222222div>
    215. <div>22222222222div>
    216. <div>22222222222div>
    217. <div>22222222222div>
    218. <div>22222222222div>
    219. <div>22222222222div>
    220. <div>22222222222div>
    221. <div>22222222222div>
    222. div>
    223. div>
    224. div>
    225. <div class="page page3">
    226. <div class="page_body hide page3_body">
    227. <div>33333333333div>
    228. <div>33333333333div>
    229. <div>33333333333div>
    230. <div>33333333333div>
    231. <div>33333333333div>
    232. <div>33333333333div>
    233. <div>33333333333div>
    234. <div>33333333333div>
    235. <div>33333333333div>
    236. <div>33333333333div>
    237. div>
    238. div>
    239. <div class="arrow">
    240. <div>
    241. <svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2859"><path d="M491.42 412.298c7.887 12.378 6.427 28.995-4.381 39.803L204.196 734.944l-90.51-90.51c-12.496-12.497-12.496-32.758 0-45.255L396.53 316.337l0.265 0.265 89.974-89.975c12.497-12.496 32.758-12.496 45.255 0l395.98 395.98-90.51 90.51c-12.497 12.497-32.758 12.497-45.255 0L491.42 412.297z" p-id="2860">path>svg>
    242. div>
    243. <div>
    244. <svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2859"><path d="M491.42 412.298c7.887 12.378 6.427 28.995-4.381 39.803L204.196 734.944l-90.51-90.51c-12.496-12.497-12.496-32.758 0-45.255L396.53 316.337l0.265 0.265 89.974-89.975c12.497-12.496 32.758-12.496 45.255 0l395.98 395.98-90.51 90.51c-12.497 12.497-32.758 12.497-45.255 0L491.42 412.297z" p-id="2860">path>svg>
    245. div>
    246. div>
    247. div>
    248. <script type="text/javascript">
    249. // element 作用区域(所有执行翻页页面的父级元素DOM)
    250. // isLoop 是否循环执行翻页
    251. // needScrollClass 执行翻页页面内部可滚动元素样式名
    252. function setChangePage(element,isLoop,needScrollClass){
    253. // console.log(element.querySelectorAll('.page'));
    254. // console.log(element.querySelectorAll('.page').length);
    255. // console.log(element.querySelector('.page'));
    256. // console.log(element.querySelector('.page2'));
    257. var pageData = {
    258. curPage:1,
    259. prevPage:null,
    260. PageL:element.querySelectorAll('.page').length,
    261. type:null,
    262. canTouch:true,
    263. startY:0,
    264. endY:0,
    265. diff:0,
    266. }
    267. var startEvt,moveEvt,endEvt;
    268. if("ontouchstart" in window){
    269. // 移动端用户滑动事件
    270. startEvt = "touchstart";
    271. moveEvt = "touchmove";
    272. endEvt = "touchend";
    273. }else{
    274. // PC端鼠标移动事件
    275. startEvt = "mousedown";
    276. moveEvt = "mousemove";
    277. endEvt = "mouseup";
    278. }
    279. element.addEventListener(startEvt, touchStart, false);
    280. element.addEventListener(moveEvt, touchMove, false);
    281. element.addEventListener(endEvt, touchEnd, false);
    282. function touchStart(e){
    283. pageData.startY = startEvt == "touchstart" ? e.touches[0].pageY : e.pageY;
    284. pageData.endY = '';
    285. pageData.diff = '';
    286. }
    287. function touchMove(e){
    288. e.preventDefault();
    289. pageData.endY = startEvt == "touchstart" ? e.touches[0].pageY : e.pageY;
    290. pageData.diff = pageData.endY - pageData.startY;
    291. }
    292. function touchEnd(e){
    293. if(Math.abs(pageData.diff) > 150 && pageData.canTouch){
    294. changeDoBefore(pageData.diff);
    295. }
    296. // setTimeout(function(){
    297. pageData.startY = '';
    298. pageData.endY = '';
    299. pageData.diff = '';
    300. // },500);
    301. }
    302. function changeDoBefore(diffNum){
    303. if(diffNum > 0){
    304. // 向下滑动进入前一页
    305. pageData.type = 2;
    306. if(pageData.curPage <= 1){
    307. if(isLoop){
    308. pageData.prevPage = 1;
    309. pageData.curPage = pageData.PageL;
    310. changeDo();
    311. }
    312. }else{
    313. pageData.prevPage = pageData.curPage;
    314. pageData.curPage--;
    315. changeDo();
    316. }
    317. }else{
    318. // 向上滑动进入下一页
    319. pageData.type = 1;
    320. if(pageData.curPage >= pageData.PageL){
    321. if(isLoop){
    322. pageData.prevPage = pageData.PageL;
    323. pageData.curPage = 1;
    324. changeDo();
    325. }
    326. }else{
    327. pageData.prevPage = pageData.curPage;
    328. pageData.curPage++;
    329. changeDo();
    330. }
    331. }
    332. }
    333. function changeDo(){
    334. if(pageData.type == 1){
    335. element.querySelector('.page' + pageData.prevPage).classList.remove('inTop' , 'outTop' , 'inDown' , 'outDown');
    336. element.querySelector('.page' + pageData.prevPage).classList.add('outTop');
    337. element.querySelector('.page' + pageData.curPage).classList.remove('inTop' , 'outTop' , 'inDown' , 'outDown');
    338. element.querySelector('.page' + pageData.curPage).classList.add('inTop');
    339. element.querySelector('.page' + pageData.curPage).querySelector('.page_body').classList.remove('hide');
    340. }else if(pageData.type == 2){
    341. element.querySelector('.page' + pageData.prevPage).classList.remove('inTop' , 'outTop' , 'inDown' , 'outDown');
    342. element.querySelector('.page' + pageData.prevPage).classList.add('outDown');
    343. element.querySelector('.page' + pageData.curPage).classList.remove('inTop' , 'outTop' , 'inDown' , 'outDown');
    344. element.querySelector('.page' + pageData.curPage).classList.add('inDown');
    345. element.querySelector('.page' + pageData.curPage).querySelector('.page_body').classList.remove('hide');
    346. }
    347. if(needScrollClass && startEvt == "touchstart"){
    348. scrollEleData.canTouch = false;
    349. setTimeout(function(){
    350. scrollEleData.canTouch = true;
    351. },500);
    352. }
    353. pageData.canTouch = false;
    354. setTimeout(function(){
    355. pageData.canTouch = true;
    356. element.querySelector('.page' + pageData.prevPage).querySelector('.page_body').classList.add('hide');
    357. },500);
    358. // 不循环切换时设置最后一页时隐藏向上箭头
    359. if(pageData.curPage >= pageData.PageL){
    360. if(!isLoop){
    361. element.querySelector('.arrow').classList.add('hide');
    362. }
    363. }else{
    364. if(!isLoop){
    365. element.querySelector('.arrow').classList.remove('hide');
    366. }
    367. }
    368. // 执行翻页页面内部可滚动时,设置进入页面后滚动条位置
    369. if(needScrollClass && element.querySelector('.page' + pageData.curPage).querySelector('.' + needScrollClass)){
    370. element.querySelector('.page' + pageData.curPage).querySelector('.' + needScrollClass).scrollTop = 0;
    371. }
    372. }
    373. // 执行翻页页面内部可滚动(移动端需要)
    374. if(needScrollClass && startEvt == "touchstart"){
    375. var scrollEleData = {
    376. canTouch:true,
    377. startY:0,
    378. endY:0,
    379. diff:0,
    380. }
    381. // console.log(element.querySelectorAll('.' + needScrollClass).length);
    382. element.querySelectorAll('.' + needScrollClass).forEach(function(item,index){
    383. // console.log(item,index);
    384. item.addEventListener("touchstart", scrollEleTouchStart, false);
    385. item.addEventListener("touchmove", scrollEleTouchMove, false);
    386. item.addEventListener("touchend", scrollEleTouchEnd, false);
    387. function scrollEleTouchStart(e){
    388. // e.stopPropagation();
    389. element.removeEventListener("touchmove", touchMove, false);
    390. scrollEleData.startY = e.touches[0].pageY;
    391. scrollEleData.endY = '';
    392. scrollEleData.diff = '';
    393. }
    394. function scrollEleTouchMove(e){
    395. scrollEleData.endY = e.touches[0].pageY;
    396. scrollEleData.diff = scrollEleData.endY - scrollEleData.startY;
    397. }
    398. function scrollEleTouchEnd(e){
    399. element.addEventListener("touchmove", touchMove, false);
    400. // console.log(scrollEleData.canTouch);
    401. if(Math.abs(scrollEleData.diff) > 150 && scrollEleData.canTouch){
    402. changeDoBefore(scrollEleData.diff);
    403. }
    404. // setTimeout(function(){
    405. scrollEleData.startY = '';
    406. scrollEleData.endY = '';
    407. scrollEleData.diff = '';
    408. // },500);
    409. }
    410. item.addEventListener("scroll", scrollDo, false);
    411. function scrollDo(e){
    412. // console.log(e.target.clientHeight , e.target.scrollTop , e.target.scrollHeight);
    413. if((e.target.clientHeight + e.target.scrollTop + 2 >= e.target.scrollHeight) || (e.target.scrollTop == 0)){
    414. setTimeout(function(){
    415. scrollEleData.canTouch = true;
    416. },500);
    417. }else{
    418. scrollEleData.canTouch = false;
    419. }
    420. }
    421. })
    422. }
    423. //
    424. window.onload = function(){
    425. element.querySelectorAll('.page').forEach(function(item,index){
    426. console.log(index)
    427. if(index > 0){
    428. item.classList.add('outTop');
    429. }else{
    430. item.classList.add('inTop');
    431. item.querySelector('.page_body').classList.remove('hide');
    432. }
    433. })
    434. }
    435. }
    436. /***************************/
    437. // 例:
    438. // 循环执行翻页
    439. setChangePage(document.getElementsByClassName('page_box')[0],'loop','scroll_box');
    440. // 不循环执行翻页
    441. // setChangePage(document.getElementsByClassName('page_box')[0],'','scroll_box');
    442. script>
    443. body>
    444. html>

  • 相关阅读:
    GitKraken Pro安装
    Posix API 和网络协议栈
    N个元素进栈 出栈情况种数
    测试面试-经典测试场景
    nest 第三章 认识nest
    systemverilog学习 --- casting and local protected
    C/C++指针之提高篇详解(二)
    在Bcache上启动OSD报unable to read osd superblock错误
    ARP协议介绍与ARP协议的攻击手法
    哈佛大学商业评论 --- 第三篇:真实世界中的增强现实
  • 原文地址:https://blog.csdn.net/qq_16494241/article/details/132741969