vue是基于node.js框架,很好的实现了mvvm,是一种轻量级的渐进式框架。
MVVM思想:view—viewmodel–model,view与model的数据通过viewmodel实现了数据的双向绑定。
安装
安装vue,cmd命令运行: npm install vue
安装vue脚手架 npm install -g @vue/cli
创建项目 helloworld
新建项目文件夹例如vueTest,使用vscode打开文件夹.
终端输入命令:
npm init -y 初始化
npm install vue 安装vue
PS C:\Users\Administrator\Desktop\vue01> npm init -y
Wrote to C:\Users\Administrator\Desktop\vue01\package.json:
{
"name": "vue01",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
PS C:\Users\Administrator\Desktop\vue01> npm install vue
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN vue01@1.0.0 No description
npm WARN vue01@1.0.0 No repository field.
+ vue@2.6.12
added 1 package from 1 contributor in 0.907s
现在vue就安装完成了,在项目下创建index.html文件,使用vue测试一下.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<h1>{{name}} Hello world</h1>
</div>
<script src="./node_modules/vue/dist/vue.js"></script>
<script>
let vm =new Vue({
el:"#app",
data:{
name:"Vue"
}
});
</script>
</body>
</html>