Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 1.12 KB

vue-cli.md

File metadata and controls

67 lines (52 loc) · 1.12 KB

vue-cli

安装

npm install -g @vue/cli

使用

创建项目:

vue create my-project
# OR
vue ui

添加模块

vue add element
vue add ......

使用 vue-router

如果要使用router功能,需要在其中加入标签<router-view></router-view>

<template>
  <div id="app">
    <navbar></navbar>
    <router-view></router-view>
  </div>
</template>

<script>
import navbar from "./components/navbar.vue";

export default {
  name: "app",
  components: {
    navbar
  }
};
</script>
<style>
</style>

大致流程

  1. index.html是主页面
  2. vue渲染其中id=app的模块
  3. 然后去看 App.vue
  4. 然后去看各种组件的组合。
  5. vue是组件式的。
  6. 通过add可以添加其他库
  7. package.json中包括各种命令生成。
  8. 运行一个npm项目,基本npm install和看package.json就行了