六十四、Vue項目去哪兒網(wǎng)App開發(fā)準(zhǔn)備

      網(wǎng)友投稿 742 2022-05-30

      @Author:Runsen

      @Date:2020/10/20

      寫在前面:我是「Runsen」,熱愛技術(shù)、熱愛開源、熱愛編程。技術(shù)是開源的、知識是共享的。大四棄算法轉(zhuǎn)前端,需要每天的日積月累, 每天都要加油!!!

      今天將正式進入Vue項目去哪兒網(wǎng)App開發(fā),下面是Vue項目去哪兒網(wǎng)App開發(fā)的準(zhǔn)備

      文章目錄

      碼云建立項目

      分析HelloVue路由

      html代碼禁止瀏覽器縮放網(wǎng)頁大小

      引入reset.css

      引入border.css

      vue.js 添加 fastclick的支持

      新建Iconfont項目

      碼云建立項目

      關(guān)于碼云建立項目,這里我PASS。建立完碼云項目,直接克隆在本地。

      下面就是創(chuàng)建Vue項目,

      npm install vue npm install cnpm npm install -g webpack # 安裝webpack npm install --global vue-cli # 全局安裝腳手架工具 vue init webpack travel# 創(chuàng)建項目(在原有的文件夾中創(chuàng)建,這樣可以將名字同步) cd travel npm run dev

      1

      2

      3

      4

      5

      6

      7

      新建項目結(jié)構(gòu)如下圖:

      結(jié)構(gòu)描述如下表:

      src核心

      src是我們代碼編寫的核心文件,其內(nèi)容如下:

      assets: 放置一些圖片,如logo等。

      components: 目錄里面放了一個組件文件,可以不用。

      App.vue: 項目入口文件,我們也可以直接將組件寫這里,而不使用components 目錄。

      main.js: 項目的核心文件。

      分析HelloVue路由

      Main.js是項目的入口

      import Vue from 'vue'//引入vue.js文件 import App from './App'//引入當(dāng)前目錄下的App.vue文件,【./】指當(dāng)前目錄,【.vue】被隱藏了 import router from './router'//引入當(dāng)前目錄下router文件夾下的Index.js文件 Vue.config.productionTip = false//屏蔽調(diào)試時的一些console日志內(nèi)容 /* eslint-disable no-new */ new Vue({ el: '#app', router,//指定路由的js對象 components: { App },//加載上方導(dǎo)入到組件。 template: ''//選擇一個組件去替換index.html 中的

      。這里使用我們components導(dǎo)入的App組件,相當(dāng)于指定初始化時的顯示組件,Vue組件注冊后可以使用的模式來使用組件。 })

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      el:估計是element的縮寫,表示Vue綁定的元素。

      router:router是我們上面引入的router文件夾下的Index.js文件,打開文件,代碼如下:

      import Vue from 'vue' import Router from 'vue-router' import HelloWorld from '@/components/HelloWorld' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld } ] })

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      代碼中開放了一個默認(rèn)的Router類型的對象,這個對象是vue-router中定義的,用于定義頁面跳轉(zhuǎn)路由,這里定義了路徑HelloWorld對應(yīng)導(dǎo)入/components/HelloWorld.vue文件。

      html代碼禁止瀏覽器縮放網(wǎng)頁大小

      html5默認(rèn)允許用戶縮放頁面,如果需要禁止縮放,我們需要在index.html添加minimum-scale=1.0,maximum-scale=1.0,user-scalabel=no

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      引入reset.css

      在HTML標(biāo)簽在瀏覽器里有默認(rèn)的樣式,例如 p 標(biāo)簽有上下邊距,strong標(biāo)簽有字體加粗樣式,em標(biāo)簽有字體傾斜樣式。因此,需要重置CSS。

      @charset "utf-8";html{touch-action: manipulation;background-color:#fff;color:#000;font-size:12px} body,ul,ol,dl,dd,h1,h2,h3,h4,h5,h6,figure,form,fieldset,legend,input,textarea,button,p,blockquote,th,td,pre,xmp{margin:0;padding:0} body,input,textarea,button,select,pre,xmp,tt,code,kbd,samp{line-height:1.5;font-family:tahoma,arial,"Hiragino Sans GB",simsun,sans-serif} h1,h2,h3,h4,h5,h6,small,big,input,textarea,button,select{font-size:100%} h1,h2,h3,h4,h5,h6{font-family:tahoma,arial,"Hiragino Sans GB","微軟雅黑",simsun,sans-serif} h1,h2,h3,h4,h5,h6,b,strong{font-weight:normal} address,cite,dfn,em,i,optgroup,var{font-style:normal} table{border-collapse:collapse;border-spacing:0;text-align:left} caption,th{text-align:inherit} ul,ol,menu{list-style:none} fieldset,img{border:0} img,object,input,textarea,button,select{vertical-align:middle} article,aside,footer,header,section,nav,figure,figcaption,hgroup,details,menu{display:block} audio,canvas,video{display:inline-block;*display:inline;*zoom:1} blockquote:before,blockquote:after,q:before,q:after{content:"

      @charset "utf-8";html{touch-action: manipulation;background-color:#fff;color:#000;font-size:12px} body,ul,ol,dl,dd,h1,h2,h3,h4,h5,h6,figure,form,fieldset,legend,input,textarea,button,p,blockquote,th,td,pre,xmp{margin:0;padding:0} body,input,textarea,button,select,pre,xmp,tt,code,kbd,samp{line-height:1.5;font-family:tahoma,arial,"Hiragino Sans GB",simsun,sans-serif} h1,h2,h3,h4,h5,h6,small,big,input,textarea,button,select{font-size:100%} h1,h2,h3,h4,h5,h6{font-family:tahoma,arial,"Hiragino Sans GB","微軟雅黑",simsun,sans-serif} h1,h2,h3,h4,h5,h6,b,strong{font-weight:normal} address,cite,dfn,em,i,optgroup,var{font-style:normal} table{border-collapse:collapse;border-spacing:0;text-align:left} caption,th{text-align:inherit} ul,ol,menu{list-style:none} fieldset,img{border:0} img,object,input,textarea,button,select{vertical-align:middle} article,aside,footer,header,section,nav,figure,figcaption,hgroup,details,menu{display:block} audio,canvas,video{display:inline-block;*display:inline;*zoom:1} blockquote:before,blockquote:after,q:before,q:after{content:"\0020"} textarea{overflow:auto;resize:vertical} input,textarea,button,select,a{outline:0 none;border: none;} button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0} mark{background-color:transparent} a,ins,s,u,del{text-decoration:none} sup,sub{vertical-align:baseline} html {overflow-x: hidden;height: 100%;font-size: 50px;-webkit-tap-highlight-color: transparent;} body {font-family: Arial, "Microsoft Yahei", "Helvetica Neue", Helvetica, sans-serif;color: #333;font-size: .28em;line-height: 1;-webkit-text-size-adjust: none;} hr {height: .02rem;margin: .1rem 0;border: medium none;border-top: .02rem solid #cacaca;} a {color: #25a4bb;text-decoration: none;}

      20"} textarea{overflow:auto;resize:vertical} input,textarea,button,select,a{outline:0 none;border: none;} button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0} mark{background-color:transparent} a,ins,s,u,del{text-decoration:none} sup,sub{vertical-align:baseline} html {overflow-x: hidden;height: 100%;font-size: 50px;-webkit-tap-highlight-color: transparent;} body {font-family: Arial, "Microsoft Yahei", "Helvetica Neue", Helvetica, sans-serif;color: #333;font-size: .28em;line-height: 1;-webkit-text-size-adjust: none;} hr {height: .02rem;margin: .1rem 0;border: medium none;border-top: .02rem solid #cacaca;} a {color: #25a4bb;text-decoration: none;}

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      引入border.css

      該css樣式用于解決移動端1像素邊框問題。問題分析:有些手機的屏幕分辨率較高,是2-3倍屏幕。css樣式中border:1px solid red;在2倍屏下,顯示的并不是1個物理像素,而是2個物理像素。為了解決這個問題,引入border.css是非常有必要的。

      @charset "utf-8"; .border, .border-top, .border-right, .border-bottom, .border-left, .border-topbottom, .border-rightleft, .border-topleft, .border-rightbottom, .border-topright, .border-bottomleft { position: relative; } .border::before, .border-top::before, .border-right::before, .border-bottom::before, .border-left::before, .border-topbottom::before, .border-topbottom::after, .border-rightleft::before, .border-rightleft::after, .border-topleft::before, .border-topleft::after, .border-rightbottom::before, .border-rightbottom::after, .border-topright::before, .border-topright::after, .border-bottomleft::before, .border-bottomleft::after { content: "

      @charset "utf-8"; .border, .border-top, .border-right, .border-bottom, .border-left, .border-topbottom, .border-rightleft, .border-topleft, .border-rightbottom, .border-topright, .border-bottomleft { position: relative; } .border::before, .border-top::before, .border-right::before, .border-bottom::before, .border-left::before, .border-topbottom::before, .border-topbottom::after, .border-rightleft::before, .border-rightleft::after, .border-topleft::before, .border-topleft::after, .border-rightbottom::before, .border-rightbottom::after, .border-topright::before, .border-topright::after, .border-bottomleft::before, .border-bottomleft::after { content: "\0020"; overflow: hidden; position: absolute; } /* border * 因,邊框是由偽元素區(qū)域遮蓋在父級 * 故,子級若有交互,需要對子級設(shè)置 * 定位 及 z軸 */ .border::before { box-sizing: border-box; top: 0; left: 0; height: 100%; width: 100%; border: 1px solid #eaeaea; transform-origin: 0 0; } .border-top::before, .border-bottom::before, .border-topbottom::before, .border-topbottom::after, .border-topleft::before, .border-rightbottom::after, .border-topright::before, .border-bottomleft::before { left: 0; width: 100%; height: 1px; } .border-right::before, .border-left::before, .border-rightleft::before, .border-rightleft::after, .border-topleft::after, .border-rightbottom::before, .border-topright::after, .border-bottomleft::after { top: 0; width: 1px; height: 100%; } .border-top::before, .border-topbottom::before, .border-topleft::before, .border-topright::before { border-top: 1px solid #eaeaea; transform-origin: 0 0; } .border-right::before, .border-rightbottom::before, .border-rightleft::before, .border-topright::after { border-right: 1px solid #eaeaea; transform-origin: 100% 0; } .border-bottom::before, .border-topbottom::after, .border-rightbottom::after, .border-bottomleft::before { border-bottom: 1px solid #eaeaea; transform-origin: 0 100%; } .border-left::before, .border-topleft::after, .border-rightleft::after, .border-bottomleft::after { border-left: 1px solid #eaeaea; transform-origin: 0 0; } .border-top::before, .border-topbottom::before, .border-topleft::before, .border-topright::before { top: 0; } .border-right::before, .border-rightleft::after, .border-rightbottom::before, .border-topright::after { right: 0; } .border-bottom::before, .border-topbottom::after, .border-rightbottom::after, .border-bottomleft::after { bottom: 0; } .border-left::before, .border-rightleft::before, .border-topleft::after, .border-bottomleft::before { left: 0; } @media (max--moz-device-pixel-ratio: 1.49), (-webkit-max-device-pixel-ratio: 1.49), (max-device-pixel-ratio: 1.49), (max-resolution: 143dpi), (max-resolution: 1.49dppx) { /* 默認(rèn)值,無需重置 */ } @media (min--moz-device-pixel-ratio: 1.5) and (max--moz-device-pixel-ratio: 2.49), (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 2.49), (min-device-pixel-ratio: 1.5) and (max-device-pixel-ratio: 2.49), (min-resolution: 144dpi) and (max-resolution: 239dpi), (min-resolution: 1.5dppx) and (max-resolution: 2.49dppx) { .border::before { width: 200%; height: 200%; transform: scale(.5); } .border-top::before, .border-bottom::before, .border-topbottom::before, .border-topbottom::after, .border-topleft::before, .border-rightbottom::after, .border-topright::before, .border-bottomleft::before { transform: scaleY(.5); } .border-right::before, .border-left::before, .border-rightleft::before, .border-rightleft::after, .border-topleft::after, .border-rightbottom::before, .border-topright::after, .border-bottomleft::after { transform: scaleX(.5); } } @media (min--moz-device-pixel-ratio: 2.5), (-webkit-min-device-pixel-ratio: 2.5), (min-device-pixel-ratio: 2.5), (min-resolution: 240dpi), (min-resolution: 2.5dppx) { .border::before { width: 300%; height: 300%; transform: scale(.33333); } .border-top::before, .border-bottom::before, .border-topbottom::before, .border-topbottom::after, .border-topleft::before, .border-rightbottom::after, .border-topright::before, .border-bottomleft::before { transform: scaleY(.33333); } .border-right::before, .border-left::before, .border-rightleft::before, .border-rightleft::after, .border-topleft::after, .border-rightbottom::before, .border-topright::after, .border-bottomleft::after { transform: scaleX(.33333); } }

      20"; overflow: hidden; position: absolute; } /* border * 因,邊框是由偽元素區(qū)域遮蓋在父級 * 故,子級若有交互,需要對子級設(shè)置 * 定位 及 z軸 */ .border::before { box-sizing: border-box; top: 0; left: 0; height: 100%; width: 100%; border: 1px solid #eaeaea; transform-origin: 0 0; } .border-top::before, .border-bottom::before, .border-topbottom::before, .border-topbottom::after, .border-topleft::before, .border-rightbottom::after, .border-topright::before, .border-bottomleft::before { left: 0; width: 100%; height: 1px; } .border-right::before, .border-left::before, .border-rightleft::before, .border-rightleft::after, .border-topleft::after, .border-rightbottom::before, .border-topright::after, .border-bottomleft::after { top: 0; width: 1px; height: 100%; } .border-top::before, .border-topbottom::before, .border-topleft::before, .border-topright::before { border-top: 1px solid #eaeaea; transform-origin: 0 0; } .border-right::before, .border-rightbottom::before, .border-rightleft::before, .border-topright::after { border-right: 1px solid #eaeaea; transform-origin: 100% 0; } .border-bottom::before, .border-topbottom::after, .border-rightbottom::after, .border-bottomleft::before { border-bottom: 1px solid #eaeaea; transform-origin: 0 100%; } .border-left::before, .border-topleft::after, .border-rightleft::after, .border-bottomleft::after { border-left: 1px solid #eaeaea; transform-origin: 0 0; } .border-top::before, .border-topbottom::before, .border-topleft::before, .border-topright::before { top: 0; } .border-right::before, .border-rightleft::after, .border-rightbottom::before, .border-topright::after { right: 0; } .border-bottom::before, .border-topbottom::after, .border-rightbottom::after, .border-bottomleft::after { bottom: 0; } .border-left::before, .border-rightleft::before, .border-topleft::after, .border-bottomleft::before { left: 0; } @media (max--moz-device-pixel-ratio: 1.49), (-webkit-max-device-pixel-ratio: 1.49), (max-device-pixel-ratio: 1.49), (max-resolution: 143dpi), (max-resolution: 1.49dppx) { /* 默認(rèn)值,無需重置 */ } @media (min--moz-device-pixel-ratio: 1.5) and (max--moz-device-pixel-ratio: 2.49), (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 2.49), (min-device-pixel-ratio: 1.5) and (max-device-pixel-ratio: 2.49), (min-resolution: 144dpi) and (max-resolution: 239dpi), (min-resolution: 1.5dppx) and (max-resolution: 2.49dppx) { .border::before { width: 200%; height: 200%; transform: scale(.5); } .border-top::before, .border-bottom::before, .border-topbottom::before, .border-topbottom::after, .border-topleft::before, .border-rightbottom::after, .border-topright::before, .border-bottomleft::before { transform: scaleY(.5); } .border-right::before, .border-left::before, .border-rightleft::before, .border-rightleft::after, .border-topleft::after, .border-rightbottom::before, .border-topright::after, .border-bottomleft::after { transform: scaleX(.5); } } @media (min--moz-device-pixel-ratio: 2.5), (-webkit-min-device-pixel-ratio: 2.5), (min-device-pixel-ratio: 2.5), (min-resolution: 240dpi), (min-resolution: 2.5dppx) { .border::before { width: 300%; height: 300%; transform: scale(.33333); } .border-top::before, .border-bottom::before, .border-topbottom::before, .border-topbottom::after, .border-topleft::before, .border-rightbottom::after, .border-topright::before, .border-bottomleft::before { transform: scaleY(.33333); } .border-right::before, .border-left::before, .border-rightleft::before, .border-rightleft::after, .border-topleft::after, .border-rightbottom::before, .border-topright::after, .border-bottomleft::after { transform: scaleX(.33333); } }

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      六十四、Vue項目去哪兒網(wǎng)App開發(fā)準(zhǔn)備

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      89

      90

      91

      92

      93

      94

      95

      96

      97

      98

      99

      100

      101

      102

      103

      104

      105

      106

      107

      108

      109

      110

      111

      112

      113

      114

      115

      116

      117

      118

      119

      120

      121

      122

      123

      124

      125

      126

      127

      128

      129

      130

      131

      132

      133

      134

      135

      136

      137

      138

      139

      140

      141

      142

      143

      144

      145

      146

      147

      148

      149

      150

      151

      152

      153

      154

      155

      156

      157

      158

      159

      160

      161

      162

      163

      164

      165

      166

      167

      168

      169

      170

      171

      172

      173

      174

      175

      176

      177

      178

      179

      180

      181

      182

      183

      184

      vue.js 添加 fastclick的支持

      fastclick:處理移動端click事件300毫秒延遲。

      安裝:npm install fastclick --sava

      之后,在main.js中引入,并綁定到body。

      import Vue from 'vue' import App from './App' import router from './router' import fastClick from 'fastclick' import './assets/styles/reset.css' import './assets/styles/border.css' Vue.config.productionTip = false fastClick.attach(document.body) /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '' })

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      新建Iconfont項目

      參考課程:慕課網(wǎng)Vue2.5->2.6->3.0 開發(fā)去哪兒網(wǎng)App 從零基礎(chǔ)入門到實戰(zhàn)項目開發(fā)

      Vue 移動APP

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:多線程和高并發(fā)搞不懂?還談什么面試?(附面試題解析)
      下一篇:python爬蟲應(yīng)用實戰(zhàn)-如何爬取好看的小姐姐照片?
      相關(guān)文章
      久久久久亚洲AV无码观看| 国产日产亚洲系列| 香蕉蕉亚亚洲aav综合| 国外亚洲成AV人片在线观看| 亚洲?V乱码久久精品蜜桃 | 亚洲中文字幕无码不卡电影| 亚洲国产精品自在拍在线播放| 国产精品观看在线亚洲人成网| 亚洲AV无码成人精品区日韩| 亚洲成a∧人片在线观看无码| 亚洲人成色99999在线观看| 亚洲日韩精品国产3区| 亚洲国产精品美女久久久久| 亚洲日韩乱码中文字幕| 亚洲性无码一区二区三区| 亚洲日本在线电影| 国产亚洲欧美在线观看| 亚洲Av无码国产一区二区| 国产亚洲精品国产福利在线观看| 国产精品亚洲专区在线播放| 亚洲av成人一区二区三区在线观看| 男人的天堂亚洲一区二区三区 | 亚洲欧洲免费视频| 久久亚洲精品无码aⅴ大香| 亚洲第一页在线播放| 亚洲an日韩专区在线| 中文字幕乱码亚洲精品一区 | 亚洲熟妇AV日韩熟妇在线| 亚洲爆乳无码精品AAA片蜜桃| 蜜桃传媒一区二区亚洲AV| 四虎亚洲国产成人久久精品| 亚洲精品人成无码中文毛片| 亚洲熟妇av一区二区三区| 亚洲爆乳无码一区二区三区| 亚洲色欲色欲综合网站| 亚洲成人免费电影| 亚洲人成欧美中文字幕| 国产亚洲精彩视频| 亚洲精品国精品久久99热一| 亚洲AV无码AV男人的天堂| 亚洲国产精品乱码在线观看97|