Vue Cli
Vue Cli(command-line interface)
官网文档:https://cli.vuejs.org/zh/guide/installation.html
参考视频教程:https://www.imooc.com/video/20123
安装Vue
## 全局安装vue
npm install -g @vue/cli
## 查看版本
vue --version
创建项目
方式一:使用npm(主流方式)
## 创建名为 hello-world 的项目
vue create hello-world
方式二:图形界面(直观,但速度慢)
## 启动vue图形界面,通过图形界面创建和管理项目
vue ui
运行过程
index.html 是项目入口文件
main.js是项目的逻辑入口文件,在index.html执行完成后自动运行,虽然在index.html中并未引用,但它相当于index.html中js
App.vue是项目的根组件,是在main.js中被挂载到index.html中的
添加实例 property
可以通过在原型上定义属性或方法,使其在每个 Vue 的实例中可用(推荐原型属性名前加$,以便与已有属性进行区分)
Vue.prototype.$appName = 'My App'