Vue 项目结构介绍

项目结构

.

├── build      // 构建脚本   打包工具webpack有关的
├── config    // 全局配置   比如index.js:  端口配置
├── node_modules // 项目依赖模块
├── src         //项目源代码
├── static     // 静态资源
├── package.jspon // 项目信息和依赖配置

└── package-lock.jspon // 项目信息和依赖配置的详细信息

src
├── api // 各种接口
├── assets // 图片等资源
├── components // 各种公共组件,非公共组件在各自view下维护
├── icons //svg icon
├── router // 路由表
├── store // 存储
├── styles // 各种样式
├── utils // 公共工具,非公共工具,在各自view下维护
├── views // 各种layout
├── App.vue //***项目顶层组件***
├── main.js //***项目入口文件***
└── permission.js //认证入口

加载流程

@ 代表src目录下

1、main.js 

import Vue from 'vue'
import App from '@/App'
import router from '@/router'  
new Vue({
  el: '#app',   // 用来挂载页面的app元素
  router,       // 全写为 router:router
  template: '<App/>',  // App.vue 中的template
  components: { App }  // 全写为 App :App 
})

2、App.vue 

<template>
  <div name="app">
    <router-view></router-view>  // 路由视图
     <router-link to='/hello'>to hello </router-link>
  </div >
</template>

<script>
  export default {
        name: 'App'
  }
</script>

3、index.js

import Vue from 'vue'
import Router from 'vue-router'

import helloword from '@compont/helloword'

import hello from '@compont/hello.'

Vue.use(Router)
export default router({
      routes:[
                {
                 path: '/',
                 name: ''helloword,
                 componet: helloword
                },
               {
                 path: '/hello',
                 name: ''helloword,
                 componet: hello 
                }
             ]
})

4、hello.vue 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值