【vue3.0】26.0 某東到家( 廿六)——不同設(shè)備適配和項(xiàng)目上線

不同設(shè)備適配

目前是針對(duì)普通手機(jī)的屏幕尺寸設(shè)計(jì)桶良,如果需要適配比如平板電腦座舍,等比例放大,需要進(jìn)行設(shè)備配置陨帆。
修改public\index.html
只需要在title后面增加如下代碼:

    <script>
      // 設(shè)備屏幕的寬度
      var width = document.documentElement.clientWidth || document.body.clientWidth
      var ratio = width / 375
      var fontSize = 100 * ratio
      // 獲得第一個(gè)html標(biāo)簽
      document.getElementsByTagName('html')[0].style['font-size'] = fontSize + 'px'
    </script>

整體代碼如下:

<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <title><%= htmlWebpackPlugin.options.title %></title>
    <script>
      // 設(shè)備屏幕的寬度
      var width = document.documentElement.clientWidth || document.body.clientWidth
      var ratio = width / 375
      var fontSize = 100 * ratio
      // 獲得第一個(gè)html標(biāo)簽
      document.getElementsByTagName('html')[0].style['font-size'] = fontSize + 'px'
    </script>
  </head>
  <body>
    <noscript>
      <strong
        >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without
        JavaScript enabled. Please enable it to continue.</strong
      >
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>
項(xiàng)目上線

新建vue.config.js

// 1. npm run build 打包代碼
// 2. 把代碼給后端
// 3. 后端把前端代碼放入后端工程
// 4. 后端重啟后端服務(wù)
// * 容易出問題的就是下面的配置
module.exports = {
  publicPath: '/moudong'
}
image.png

正在打包中:


image.png

打包完成:


image.png

然后把dist目錄發(fā)給后端人員即可曲秉,由他們?nèi)グl(fā)布。
image.png

到此疲牵,本項(xiàng)目學(xué)習(xí)課程全部結(jié)束承二,之后如有內(nèi)容都是自己在巨人的肩膀上全新編寫。

目前整個(gè)項(xiàng)目涉及的所有接口如下:

[{
  "name": "獲取訂單列表",
  "url": "/api/order",
  "method": "get",
  "on": true
}, {
  "name": "創(chuàng)建訂單",
  "url": "/api/createOrder",
  "method": "post",
  "on": true
}, {
  "name": "查詢商店的商品列表",
  "url": "/api/shop/:id/products",
  "method": "get",
  "on": true
}, {
  "name": "商店詳情",
  "url": "/api/shop/:id",
  "method": "get",
  "on": true
}, {
  "name": "熱門店鋪",
  "url": "/api/user/hot_list",
  "method": "get",
  "on": true
}, {
  "name": "注冊(cè)",
  "url": "/api/user/register",
  "method": "post",
  "on": true
}, {
  "name": "登錄",
  "url": "/api/user/login",
  "method": "post",
  "on": true
}]

接口數(shù)據(jù)如下:

[{
  "delay": 0,
  "name": "獲取訂單列表",
  "method": "get",
  "url": "/api/order",
  "description": "返回商品的所有訂單信息纲爸,用于前端展示",
  "on": 1,
  "create_time": "2021-12-02T08:45:54.000Z",
  "update_time": "2021-12-02T09:47:07.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "{\r\n  \"code\": 200,\r\n  \"data\": [\r\n    {\r\n      \"address\": {\r\n        \"city\": \"北京\",\r\n        \"department\": \"xx小區(qū)\",\r\n        \"houseNumber\": \"門牌號(hào)\",\r\n        \"name\": \"張三\",\r\n        \"phone\": \"18012341234\"\r\n      },\r\n      \"shopId\": \"1\",\r\n      \"shopName\": \"某什么碼1\",\r\n      \"isCanceled\": false,\r\n      \"products\": [\r\n        {\r\n          \"orderSales\": 5,\r\n          \"product\": {\r\n            \"name\": \"番茄250g/份\",\r\n            \"imgUrl\": \"/i18n/9_16/img/tomato.png\",\r\n            \"sales\": 10,\r\n            \"price\": 33.6\r\n          }\r\n        },\r\n        {\r\n          \"orderSales\": 10,\r\n          \"product\": {\r\n            \"name\": \"櫻桃250g/份\",\r\n            \"imgUrl\": \"/i18n/9_16/img/cherry.png\",\r\n            \"sales\": 10,\r\n            \"price\": 79.6\r\n          }\r\n        },\r\n        {\r\n          \"orderSales\": 8,\r\n          \"product\": {\r\n            \"name\": \"帝王蟹250g/份\",\r\n            \"imgUrl\": \"/i18n/9_16/img/crab.png\",\r\n            \"sales\": 10,\r\n            \"price\": 159.6\r\n          }\r\n        },\r\n        {\r\n          \"orderSales\": 4,\r\n          \"product\": {\r\n            \"name\": \"橙子250g/份\",\r\n            \"imgUrl\": \"/i18n/9_16/img/orange.png\",\r\n            \"sales\": 10,\r\n            \"price\": 92.6\r\n          }\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"desc\": \"成功\"\r\n}\r\n"
}, {
  "delay": 0,
  "name": "創(chuàng)建訂單",
  "method": "post",
  "url": "/api/createOrder",
  "description": null,
  "on": 1,
  "create_time": "2021-11-29T19:57:00.000Z",
  "update_time": "2021-11-29T20:10:42.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "    /**\r\n     * 輸入\r\n     * conten-type:json\r\n     * body:{\r\n       addressId:“xxx”//收貨地址 id\r\n       shopId:\"\"http://商店id\r\n       shopName:\"某什么碼1\",\r\n       isCanceled:false,//訂單是否被取消了\r\n       products:[\r\n       {\r\n         id:\"xxx\",//商品id\r\n         num:6//商品數(shù)量\r\n       }, \r\n       {\r\n         id:\"xxx\",//商品id\r\n         num:6//商品數(shù)量\r\n       },\r\n       ]\r\n     }\r\n     **/\r\n    {\r\n      \"code\": 200,\r\n      \"data\": {   _id: '1',},\r\n      \"desc\": \"成功\"\r\n    }"
}, {
  "delay": 0,
  "name": "查詢商店的商品列表",
  "method": "get",
  "url": "/api/shop/:id/products",
  "description": "id:動(dòng)態(tài)參數(shù)亥鸠,即商店id\n?tab=all  tab(頁(yè)面左側(cè)tab),可作為query",
  "on": 1,
  "create_time": "2021-10-13T17:49:26.000Z",
  "update_time": "2021-10-15T12:44:40.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "    {\r\n      \"code\": 200,\r\n      \"data\": [{\r\n          _id: '1',\r\n          name: '番茄250g/份',\r\n          imgUrl: '/i18n/9_16/img/tomato.png',\r\n          sales: 10,\r\n          price: 33.6,\r\n          oldPrice: 39.6\r\n        },\r\n        {\r\n          _id: '2',\r\n          name: '櫻桃250g/份',\r\n          imgUrl: '/i18n/9_16/img/cherry.png',\r\n          sales: 10,\r\n          price: 79.6,\r\n          oldPrice: 59.6\r\n        },\r\n        {\r\n          _id: '3',\r\n          name: '帝王蟹250g/份',\r\n          imgUrl: '/i18n/9_16/img/crab.png',\r\n          sales: 10,\r\n          price: 159.6,\r\n          oldPrice: 149.6\r\n        },\r\n        {\r\n          _id: '4',\r\n          name: '橙子250g/份',\r\n          imgUrl: '/i18n/9_16/img/orange.png',\r\n          sales: 10,\r\n          price: 92.6,\r\n          oldPrice: 85.6\r\n        }\r\n      ],\r\n      \"desc\": \"成功\"\r\n    }"
}, {
  "delay": 300,
  "name": "商店詳情",
  "method": "get",
  "url": "/api/shop/:id",
  "description": "id為動(dòng)態(tài)參數(shù)识啦,為商店店鋪id",
  "on": 1,
  "create_time": "2021-07-19T04:34:47.000Z",
  "update_time": "2021-10-13T16:20:01.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "{\r\n  \"code\": 200,\r\n  \"data\": {\r\n      id: '1',\r\n      name: '某什么瑪1',\r\n      imgUrl: '/i18n/9_16/img/near.png',\r\n      sales: 200,\r\n      expressLimit: 0,\r\n      expressPrice: 5,\r\n      slogon: 'VIP尊享xx元減x元運(yùn)費(fèi)券(每月x張)'\r\n  },\r\n  \"desc\": \"成功\"\r\n}"
}, {
  "delay": 300,
  "name": "熱門店鋪",
  "method": "get",
  "url": "/api/user/hot_list",
  "description": "熱門店鋪",
  "on": 1,
  "create_time": "2021-07-17T14:54:21.000Z",
  "update_time": "2021-07-19T03:09:54.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "{\r\n  code: 200,\r\n  data: [\r\n    {\r\n      id: '1',\r\n      name: '某什么瑪1',\r\n      imgUrl: '/i18n/9_16/img/near.png',\r\n      sales: 1000,\r\n      expressLimit: 0,\r\n      expressPrice: 5,\r\n      slogon: 'VIP尊享xx元減x元運(yùn)費(fèi)券(每月x張)'\r\n    },\r\n    {\r\n      id: '2',\r\n      name: '某什么瑪2',\r\n      imgUrl: '/i18n/9_16/img/near.png',\r\n      sales: 2000,\r\n      expressLimit: 0,\r\n      expressPrice: 5,\r\n      slogon: 'VIP尊享xx元減x元運(yùn)費(fèi)券(每月x張)'\r\n    },\r\n    {\r\n      id: '3',\r\n      name: '某什么瑪3',\r\n      imgUrl: '/i18n/9_16/img/near.png',\r\n      sales: 200,\r\n      expressLimit: 0,\r\n      expressPrice: 5,\r\n      slogon: 'VIP尊享xx元減x元運(yùn)費(fèi)券(每月x張)'\r\n    },\r\n    {\r\n      id: '4',\r\n      name: '某什么瑪4',\r\n      imgUrl: '/i18n/9_16/img/near.png',\r\n      sales: 100,\r\n      expressLimit: 0,\r\n      expressPrice: 5,\r\n      slogon: 'VIP尊享xx元減x元運(yùn)費(fèi)券(每月x張)'\r\n    }\r\n  ],\r\n  desc: '成功'\r\n}"
}, {
  "delay": 300,
  "name": "注冊(cè)",
  "method": "post",
  "url": "/api/user/register",
  "description": "注冊(cè)保存",
  "on": 1,
  "create_time": "2021-07-17T04:32:34.000Z",
  "update_time": "2021-07-17T14:40:09.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "{\r\n  \"code\": 200,\r\n  \"data\": {\r\n  },\r\n  \"desc\": \"成功\"\r\n}"
}, {
  "delay": 300,
  "name": "登錄",
  "method": "post",
  "url": "/api/user/login",
  "description": "登錄驗(yàn)密",
  "on": 1,
  "create_time": "2021-07-16T15:28:29.000Z",
  "update_time": "2021-07-17T04:32:56.000Z",
  "project": 36763,
  "create_user": null,
  "folder_id": 0,
  "mock_rule": "{\r\n  \"code\": 200,\r\n  \"data\": {\r\n  \r\n  },\r\n  \"desc\": \"成功\"\r\n}"
}]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末读虏,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子袁滥,更是在濱河造成了極大的恐慌,老刑警劉巖灾螃,帶你破解...
    沈念sama閱讀 206,214評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件题翻,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡腰鬼,警方通過查閱死者的電腦和手機(jī)嵌赠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,307評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來熄赡,“玉大人姜挺,你說我怎么就攤上這事”肆颍” “怎么了炊豪?”我有些...
    開封第一講書人閱讀 152,543評(píng)論 0 341
  • 文/不壞的土叔 我叫張陵凌箕,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我词渤,道長(zhǎng)牵舱,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,221評(píng)論 1 279
  • 正文 為了忘掉前任缺虐,我火速辦了婚禮芜壁,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘高氮。我一直安慰自己慧妄,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,224評(píng)論 5 371
  • 文/花漫 我一把揭開白布剪芍。 她就那樣靜靜地躺著塞淹,像睡著了一般。 火紅的嫁衣襯著肌膚如雪紊浩。 梳的紋絲不亂的頭發(fā)上窖铡,一...
    開封第一講書人閱讀 49,007評(píng)論 1 284
  • 那天,我揣著相機(jī)與錄音坊谁,去河邊找鬼费彼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛口芍,可吹牛的內(nèi)容都是我干的箍铲。 我是一名探鬼主播,決...
    沈念sama閱讀 38,313評(píng)論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼鬓椭,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼颠猴!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起小染,我...
    開封第一講書人閱讀 36,956評(píng)論 0 259
  • 序言:老撾萬榮一對(duì)情侶失蹤翘瓮,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后裤翩,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體资盅,經(jīng)...
    沈念sama閱讀 43,441評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,925評(píng)論 2 323
  • 正文 我和宋清朗相戀三年踊赠,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了呵扛。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,018評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡筐带,死狀恐怖今穿,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情伦籍,我是刑警寧澤蓝晒,帶...
    沈念sama閱讀 33,685評(píng)論 4 322
  • 正文 年R本政府宣布腮出,位于F島的核電站,受9級(jí)特大地震影響拔创,放射性物質(zhì)發(fā)生泄漏利诺。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,234評(píng)論 3 307
  • 文/蒙蒙 一剩燥、第九天 我趴在偏房一處隱蔽的房頂上張望慢逾。 院中可真熱鬧,春花似錦灭红、人聲如沸侣滩。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,240評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽君珠。三九已至,卻和暖如春娇斑,著一層夾襖步出監(jiān)牢的瞬間策添,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,464評(píng)論 1 261
  • 我被黑心中介騙來泰國(guó)打工毫缆, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留唯竹,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 45,467評(píng)論 2 352
  • 正文 我出身青樓苦丁,卻偏偏與公主長(zhǎng)得像浸颓,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子旺拉,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,762評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容