1. 設為首頁   文化中國網歡迎您~!

          @vue/cli 使用路由router,狀態機vuex,sass, elementUi餓了么組件

          本文章主要介紹 @vue/cli 使用路由router,狀態機vuex,sass, elementUi餓了么組件 的安裝以及使用時注意事項

          • 安裝
          1.npm install vue-router
          2.npm install vuex --save
          3.npm install -D sass-loader node-sass
          4.npm i element-ui -S
          vue add element
          • 相應的代碼文件修改:

          1.main.js中render頁面時使用router屬性

          文件路徑: src/router/index.js

          import Vue from 'vue'import Router from 'vue-router'Vue.use(Router)export default new Router({  routes: [    {      path: '/',      redirect: 'index'    },    {      path: '/index',      name: 'index',      redirect: 'homepage'    },    {      path: '/homepage',      name: 'homepage',      component: () => import('@/pages/Main'),      children: [        {path: '', component: () => import('@/components/content/middle/components/Test1')}      ]    }  ]})

          2.src/main.js

          import Vue from 'vue'import vuex from 'vuex'import App from './App.vue'import './plugins/element.js'import router from './router'Vue.use(vuex)Vue.config.productionTip = falsenew Vue({  render: h => h(App),  router}).$mount('#app')

          3.src/App.vue中配置頂層的router-view

          <template>  <div id="root">    <!-- <img alt="Vue logo" src="./assets/logo.png"> -->    <router-view/>  </div></template>

          小總結:

          1.當然如果不想將第一層的router-view寫在App.vue文件里面的話,也可以寫在別的文件里面。

          2.根路徑 '/' 直接指向的是main.js中render的組件(頁面)。

          3.vue-router實例中的routes屬性,配置的都是children, 包括第一層數組也是children,屬性名是routes。所以對于第一層的router-view可以有多個頁面,就是通過第一層數組中的不同的path+component來配置

          4.vue-router實例中的routes屬性中的children中的每個對象,都可以再擁有自己的children。

          github repo link: https://github.com/mxlgsq/vue3-demo.git

          好运来 www.1314xing.com:巧家县| www.puzzle-tours.com:静乐县| www.takethiscash.com:鹤壁市| www.bjgyxw.com:沙湾县| www.99069dd.com:手游| www.daleysretreat.com:囊谦县| www.rippan.com:乌海市| www.zainvista.com:卓尼县| www.rareearthsoil.com:磐石市| www.kootenaylodge.com:盘山县| www.shlsdp.com:渭南市| www.smashingoffernow.com:安多县| www.essenceofmassage.com:青铜峡市| www.kzftp.com:永康市| www.findnewyorkclubs.com:苏州市| www.bulgariatourguide.com:类乌齐县| www.freeintimo.com:新龙县| www.janvanlysebettens.com:临清市| www.gthforex.com:隆德县| www.ahtydzs.com:习水县| www.dantealighieribsb.com:久治县| www.7vui.com:万盛区| www.victorhugor.com:永平县| www.cp5517.com:阳朔县| www.shshangxin.com:岳普湖县| www.bbcgj.com:延津县| www.miguelduhamel.com:砀山县| www.anahuacpn.com:贵南县| www.208650.com:安顺市| www.w-b-z.com:通州市| www.konkurenz.com:务川| www.esb8589.com:朝阳市| www.caboverdedesign.com:酒泉市| www.afterindia.com:陆川县| www.migliorecoffee.com:北宁市| www.sadosanmakina.com:新宁县| www.qqrbc.com:宜昌市| www.kdjbw.cn:玛曲县| www.wagescout.com:五原县| www.acehobbyaustralia.com:定南县| www.clickablevideoads.com:蓝田县| www.99533b.com:兴海县| www.xianglinhe.com:南溪县| www.esfhera.com:汉寿县| www.markctalbot.com:绥棱县| www.summeranciationalize.com:老河口市| www.pstee.com:盐城市| www.porcoespirito.com:永清县| www.vermord.com:盐池县| www.cencorjeans.com:吴旗县| www.jam-bg.com:博野县| www.weieixuan.com:长武县| www.baikalwaves.com:东阳市| www.sanwencaipiao.com:山阴县| www.headsickpinups.com:弥渡县| www.cambiemosgalapagar.net:怀仁县| www.stephanmueller.net:平潭县| www.elalumbramiento.org:横山县| www.ostseeportal.org:女性| www.imaxsurfacecoating.com:吉隆县| www.marcusminge.com:襄汾县| www.bash4guild.com:洛浦县| www.amzabawki.com:日土县| www.informasijakarta.com:雷波县| www.lxglc.cn:苏州市| www.aidu49.com:淳安县| www.gm445.com:台东市| www.dennisforhire.com:康乐县| www.isabel-duque.com:岳西县| www.netepan.com:蓝田县| www.ccsql.com:江山市| www.dx557.com:剑河县| www.witbankguesthouseaccommodation.com:云南省| www.spaziotrearredamenti.com:泰安市| www.ptlins.com:钟山县| www.krankgolfasia.com:兴海县| www.n3969.com:巨鹿县| www.mypopularbrand.com:习水县| www.ujaxu.com:砚山县| www.esb8589.com:安多县| www.safehavenproj.org:务川| www.zzysww.com:博白县| www.studiocopyright.com:延川县| www.parachuteins.com:裕民县|