政见CNPolitics拆掉知识的高墙 2018-05-22
Vue-cli 是 vue的设计者,为提升开发效率而提供的一个脚手架工具,可通过vue-cli快速构造项目结构
npm config set registry https://registry.npm.taobao.org
npm install cnpm -g
cnpm install webpack webpack-cli –g
cnpm install webpack webpack-cli --save-dev
cnpm install vue-cli -g
Test.vue 代码
<template> <div> <h1>Test组件</h1> </div> </template> <script> export default{ } </script> <style> h1{color:green} </style>
index.js 代码(红色部分)
import Vue from 'vue' import Router from 'vue-router' import HelloWorld from '@/components/HelloWorld' import Test from '@/components/Test' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld }, { path: '/test', name: 'Test', component: Test } ] })