Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架。与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用。Vue 的核心库只关注视图层(HTML+JS+CSS),不仅易于上手,还便于与第三方库或既有项目整合。另一方面,当与现代化的工具链以及各种支持类库结合使用时,Vue 也完全能够为复杂的单页应用提供驱动。
开发者为尤雨溪
网络通信:axios
页面跳转:vue-router
状态管理:vuex
VUE-UI:ICE
内容补充
CSS预处理器:给CSS添加了一点编程的特性,是一门新的语言
vue:一款渐进式js框架,所谓渐进式就是逐步实现新特性的意思,如实现模块化开发、路由、状态管理等新特性。其特点是综合了Angular(模块化)和React(虚拟DOM)的优点
axios:前端通信框架,因为vue的边界很明确,就是为了处理DOM,所以不具有通信嫩里,这个时候就需要额外使用一个通信框架与服务器交互,当然也可以直接使用jQuery提供的AJAX功能

vue-element-admin: vue-element-admin (panjiachen.github.io)
node.js: Node.js 教程 | 菜鸟教程 (runoob.com)


常见的前端开发工具:vscode、webstorm
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
-
- <div id="app">
- <h1> {{message}}h1>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: "hello vue"
- }
- });
- script>
-
-
- body>
- html>

学习前端:
判断-循环(if for)
v-if和v-for的使用
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
- <div id="app">
- <h1 v-if="message">显示h1>
- <h1 v-else>不显示h1>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: true
- }
- });
- script>
- body>
- html>
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
-
- <div id="app">
- <h1 v-for="item in items">
- {{item.message}}
- h1>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- items: [{
- message: "hahaha"},
- { message: "呵呵呵呵呵呵"}
- ]
- }
- });
- script>
- body>
- html>
- html>
- <html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
-
- <div id="app">
- <button v-on:click="hello">点击button>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: "hello vue"
- },
- methods:{
- //这里需要添加一个事件来响应
- hello: function (event) {
- alert(this.message)
- }
- }
- });
- script>
-
-
- body>
- html>
在vue中是这样的

在jsp中是:
- function XXX(){
-
- }
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
- <div id="app">
- <input type="text" v-model="message"/>
- {{message}}
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: "hello vue"
- }
- });
- script>
- body>
- html>
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
- <div id="app">
- <input type="radio" name="boy" value="男" v-model="checked"/> 男
- <input type="radio" name="girl" value="女" v-model="checked"/> 女
- <p>
- 选择的性别为:{{checked}}
- p>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: "hello vue",
- checked: ""
- }
- });
- script>
- body>
- html>
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
- <div id="app">
-
- <select v-model="xuanzhong">
- <option value="" disabled>--请选择--option>
- <option>Aoption>
- <option>Boption>
- <option>Coption>
- select>
- <p> 选中的为:{{xuanzhong}}p>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: "hello vue",
- checked: "",
- xuanzhong: ""
- }
- });
- script>
- body>
- html>
这里使用disabled是让他变成不可交互的,在这里也就是不准在下拉框中选择它

- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <body>
-
- <div id="app">
-
- <haha v-for="item in items" v-bind:bangding="item">haha>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
-
- Vue.component("haha",{
- props: ['bangding'],
- template: '
- {{bangding}}
' - }
-
- )
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- items: ["java","python","C++"]
- }
- });
- script>
-
- body>
- html>



使用axios必须将idea中的JavaScript修改为6的版本及以上

实现代码:
- html>
- <html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
-
- <head>
- <meta charset="UTF-8">
- <title>axiostitle>
-
- <style>
- [v-cloak] {
- display: none;
- }
- style>
- head>
- <body>
- <div id="vue" v-cloak>
- <div>{{info.name}}div>
- <div>{{info.address.street}}div>
- <div>{{info.links}}div>
- <a v-bind:href="info.url">点我a>
- div>
-
- <script type="text/javascript" src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js">script>
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- var vm = new Vue({
- el: "#vue",
- data: function () {
- return {
- // 请求的返回参数名,必须和 json 字符串一样
- info: {
- name: null,
- address: {
- street: null,
- city: null,
- country: null
- },
- url: null,
- links: [
- {
- name: null,
- url: null
- }
- ]
- }
- }
- },
- mounted: function () { // 钩子函数 链式编程 ES6新特性
- axios.get('../data.json').then(response => (this.info = response.data))
- }
- });
- script>
- body>
- html>
我们来补充以下ajax的一些概念:
Ajax是指一种创建交互式、快速动态网页应用的网页开发技术,无需重新加载整个网页的情况下,能够更新部分网页的技术。传统的网页(不使用AJAX)如果需要更新内容,必须重载整个网页页面。
AJAX实现方式有两种:
- 1)原生的JS实现方式:了解即可,了解即可,了解即可,实际项目中基本用的是下一种;
- 2)JQuery实现方式:.ajax()、.get()、
【实现步骤】:
- 1)创建核心对象
- 2)建立连接(方法的参数解释详见下面代码);
- 3)发送请求;
- 4)接收及处理响应结果。
也就是说计算出来的结果保存在属性中,内存中运行;减轻了浏览器的压力!
- html>
- <html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- head>
- <div id="app">
- <p>{{hello()}}p>
- <p>{{hello1}}p>
- div>
-
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
- /*2. 创建vue对象*/
- var vm=new Vue({
- /*3. 绑定*/
- el: "#app",
- /*4. 放置数据 model层*/
- data: {
- message: "hello vue"
- },
- methods:{
- hello: function () {
- return Date.now();
- }
- },
- computed:{
- hello1: function(){
- return Date.now();
- }
- }
- });
- script>
- html>

- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- <style>
-
- [v-cloak ]{
- display: none !important;
- }
- style>
- head>
- <body>
- <div id="app" v-cloak>
- <todo>
- <todo-title slot="todo-title" :title="title">todo-title>
- <todo-items slot="todo-items" v-for="item in todoItems" :item="item">todo-items>
- todo>
- div>
- <script type="text/javascript" src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js">script>
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
-
- //slot: 插槽
- Vue.component("todo",{
- template:
- '' +
- '
' + - '
'
+ - '
' + - '' +
- ''
-
- });
-
-
- Vue.component("todo-title",{
- props: ["title"],
- template: '{{title}}'
- });
-
- Vue.component("todo-items",{
- props: ["item"],
- template: '
- {{item}}
' - });
-
- var vm=new Vue({
- el:'#app',
- data: {
- title: "haha的列表",
- todoItems: ['haha','zengyueqing','yeye']
- }
-
-
-
- });
- script>
- body>
- html>
-
-


- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- <style>
-
- [v-cloak ]{
- display: none !important;
- }
- style>
- head>
- <body>
- <div id="app" v-cloak>
- <todo>
- <todo-title slot="todo-title" :title="title">todo-title>
- <todo-items slot="todo-items" v-for="(item,index) in todoItems" :item="item" :index="index" v-on:remove="removeItem(index)" :key="index">todo-items>
- todo>
- div>
- <script type="text/javascript" src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js">script>
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">script>
- <script>
-
- //slot: 插槽
- Vue.component("todo",{
- template:
- '' +
- '
' + - '
'
+ - '
' + - '' +
- ''
-
- });
-
-
- Vue.component("todo-title",{
- props: ["title"],
- template: '{{title}}'
- });
-
- Vue.component("todo-items",{
- props: ["item","index"],
- //click 只能绑定当前的方法
- template: '
- {{index}}----------{{item}}
', - methods: {
- remove: function (index) {
- //this.$emit 调用v:on的自定义事的方法
- this.$emit('remove',index);
- }
- }
- });
-
- var vm=new Vue({
- el:'#app',
- data: {
- title: "luyi的列表",
- todoItems: ['luyi','zengyueqing','luz']
-
- },
- methods:{
- removeItem: function (index) {
- console.log("删除了"+this.todoItems[index]+"ok");
- this.todoItems.splice(index,1);
- }
- }
-
- });
- script>
- body>
- html>
-
-

①安装淘宝镜像
(2条消息) npm配置国内镜像(淘宝镜像)_young_man2的博客-CSDN博客_npm 设置国内镜像
②安装vue-cil
参照这个博客(2条消息) vue Cli(脚手架)安装_stay_少年与梦的博客-CSDN博客_安装vue-cli脚手架
手动创建一个Vue-cli项目
vue init webpack myvue命令,初始化一个基于webpack模板的vue应用程序

接下来使用 npm -install
然后使用idea打开项目
最后运行命令


3.2 下载与安装webpack的安装命令
npm install webpack-cli -g
npm install webpack -g
查看版本号

1. 创建项目

然后使用idea打开
2. 创建一个名为modules的目录,用来放置js文件
3. 创建项目来实实现
比如我们现在有一个hello.js,我们将它调用到main.js里面,然后我们使用webpack进行封装!
①hello.js
- //暴露一个方法
- exports.sayHi = function () {
- document.write("
一定要找到工作!
") - };
-
②main.js
- var helper=require("./hello")
- helper.sayHi();
③webpack.config.js
- module.exports={
- entry: "./moudles/main.js",
- output: {
- filename: "./js/bundle.js"
- }
- }
④在控制台使用webpack就可以进行打包
⑤然后他就会自动生成文件了

这个bundle.js里面就是整合了我们的main.js和hello.js的!

npm install vue-rooter --save
Vite 搭建 Vue2 项目(Vue2 + vue-router + vuex)-KuangStudy-文章
npm i element-ui -S
1. 创建项目
vue init webpack hello-vue
2.


解决错误:RunScriptError: post install error, please remove node_modules before retry!