vue-cli用处:快速搭建项目
component
.vue 单文件组件 用来存放组件 是vue独有的,浏览器不加载。所以需要加载器
.vue文件中可存放:
<template>
<!-- html -->
</template>
<style>
<!-- css -->
</style>
<script>
//js
</script>
下载及使用:
以下下载需要在git软件中使用,在git中不能使用复制粘贴的快捷键
1、安装cnpm:$ npm install -g cnpm --registry=https://registry.npm.taobao.org


2、webpack:cnpm install webpack -g


3、vue-cli:cnpm install vue-cli -g


4、创建项目:vue init webpack webpack-demo
创建项目中webpack为模板名,webpack-demo为项目名,项目名可自定义


执行完以上步骤后,进入项目文件夹完成以下步骤
注意:如果文件中没有相关依赖执行第5步,如有直接开启一个服务
5、安装相关依赖:cnpm install
相关依赖安装完成后,会有一个名为node_modules的文件夹
6、开启一个服务:npm run dev

服务开启成功后‘localhost:8080为当前项目的打开地址,8080不是固定的’,开启服务后,当前git不能关闭
7、项目完成后,需要压缩。命令为:cnpm run build(成功后文件夹会多一个dist文件)
网友评论