vue2.0 路由自动化范例

let routers = require.context('@/views', true).keys();
routers = routers.filter(item => item.indexOf(".vue") != -1);

let indexRouterArray=[];
let rtIndexRouterArrayPath={};
routers.forEach(item => {
	const paths = item.match(/[a-zA-Z]+/g) //paths中存储了一个目录,二级目录,文件名
	let pageI=item.replace(/\.\//g,"").replace(/\.vue/g,"");

	let routerData= {
		path: '/' + pageI,
		component: () => import("@/views/"+pageI),
	//如果目录下的文件名是index.vue 路由直接是目录名

console.log("自动化路由路径", rtIndexRouterArrayPath)





  1. sikis izle说道:

    I pay a quick visit each day a few websites and sites to read articles or reviews, however this webpage gives quality based writing. Gwenneth Elmer Holle

  2. sikis izle说道:

    Way cool! Some very valid points! I appreciate you writing this post and also the rest of the website is also really good. Mariann Simon Kentiggerma

  3. sikis izle说道:

    I believe you have mentioned some very interesting details, regards for the post. Catherin Nico Berry

  4. porno说道:

    You have observed very interesting details! ps nice internet site. Delly Vladimir Amalbena

  5. porn说道:

    Hello! This is my 1st comment here so I just wanted to give a quick shout out and tell you I really enjoy reading your posts. Beatriz Patric Glanville

  6. netflix说道:

    Wow, incredible blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is fantastic, let alone the content! Morna Delmore Pauwles

  7. movies说道:

    Hurrah! After all I got a blog from where I be capable of really take helpful data concerning my study and knowledge.| Antonia Cal Bent

  8. online说道:

    Excellent site. Lots of helpful information here. I am sending it to some buddies ans additionally sharing in delicious. And naturally, thank you to your sweat! Kelsy Ewan Wanfried

  9. online说道:

    Hmm is anyone else experiencing problems with the images on this blog loading? Hilliary Hersh Byrd

  10. watch online说道:

    This is one awesome article post. Really looking forward to read more. Hyacintha Kalil Ronny Evania Cornelius Clift


您的电子邮箱地址不会被公开。 必填项已用*标注

Copyright @ 2019 ARVIN 版权所有 沪ICP备19014233号-1