主頁 > 軟體設計 > 【萬字長文】 Vue全家桶從入門到實戰,超詳細筆記整理 ( 三 ) (建議收藏)

【萬字長文】 Vue全家桶從入門到實戰,超詳細筆記整理 ( 三 ) (建議收藏)

2021-08-05 08:07:36 軟體設計

目錄

    • 16、Vue CLI 腳手架
      • 16.1、什么是CLI
      • 16.2 什么是Vue CLI <====> (maven 專案構建工具)
      • 16.3 Vue CLI優勢
      • 16.4 Vue CLI安裝
        • 1、環境準備
        • 2、安裝腳手架
        • 3、第一個vue腳手架專案
        • 4、如何開發Vue腳手架
    • 17、在腳手架中使用axios
      • 17.1、安裝axios
    • 18、Vue Cli腳手架專案部署
    • 19、webstorm開發vue cli專案
      • 19.1、簡介
      • 19.2、安裝
      • 19.3、使用webstorm
      • 19.4、開發vue cli專案(一)
      • 19.5、開發vue cli專案(二)
    • 20、VueX 狀態管理
      • 20.1、簡介&安裝
      • 20.2、state屬性
      • 20.3、mutations 屬性
      • 20.4、getters 屬性
      • 20.5、練習

16、Vue CLI 腳手架

16.1、什么是CLI

命令列界面(英語:command-line interface,縮寫:CLI)是在圖形用戶界面得到普及之前使用最為廣泛的用戶界面,它通常不支持滑鼠,用戶通過鍵盤輸入指令,計算機接收到指令后,予以執行,也有人稱之為字符用戶界面(CUI)

16.2 什么是Vue CLI <====> (maven 專案構建工具)

Vue CLI 是一個基于 Vue.js 進行快速開發的完整系統, 使用Vue 腳手架之后我們開發的頁面將是一個完整系統(專案), 前端系統

16.3 Vue CLI優勢

  • 通過 vue-cli 搭建互動式的專案腳手架,
  • 通過 @vue/cli + @vue/cli-service-global 快速開始零配置原型開發
  • 一個運行時依賴 (@vue/cli-service),該依賴:
    • 可升級;
    • 基于 webpack 構建,并帶有合理的默認配置; webpack 前端打包工具 index.html vue組件 用戶組件 學生組件 … 路由 dist目錄
    • 可以通過專案內的組態檔進行配置; cli 專案組態檔 添加
    • 可以通過插件進行擴展, cli 專案里
  • 一個豐富的官方插件集合,集成了前端生態中最好的工具, webpack打包工具===>dist目錄 nodejs 服務器(tomcat java) 熱部署插件 npm包
  • 一套完全圖形化的創建和管理 Vue.js 專案的用戶界面

16.4 Vue CLI安裝

1、環境準備

# 1.下載nodejs
	http://nodejs.cn/download/
		windows系統:   .msi  安裝包(exe)指定安裝位置   .zip(壓縮包)直接解壓縮指定目錄
		mac os 系統:   .pkg  安裝包格式自動配置環境變數  .tar.gz(壓縮包)解壓縮安裝到指定名

# 2.配置nodejs環境變數
	1.windows系統:
	 	計算上右鍵屬性---->  高級屬性 ---->環境變數 添加如下配置:
		NODE_HOME=  nodejs安裝目錄
        PATH    = xxxx;%NODE_HOME%
    2.macos 系統
    	推薦使用.pkg安裝直接配置node環境

# 3.驗證nodejs環境是否成功
	node -v 

# 4.npm介紹
	node package mangager   nodejs包管理工具       前端主流技術  npm 進行統一管理
	maven 管理java后端依賴    遠程倉庫(中心倉庫)      阿里云鏡像
	npm   管理前端系統依賴     遠程倉庫(中心倉庫)      配置淘寶鏡像

# 5.配置淘寶鏡像
	  npm config set registry https://registry.npm.taobao.org
	  npm config get registry

# 6.配置npm下載依賴位置
	 windows:
		npm config set cache "D:\nodereps\npm-cache"
		npm config set prefix "D:\nodereps\npm_global"
	 mac os:
	 	npm config set cache "/Users/chenyannan/dev/nodereps"
		npm config set prefix "/Users/chenyannan/dev/nodereps"

# 7.驗證nodejs環境配置
	npm config ls
    ; userconfig /Users/chenyannan/.npmrc
    cache = "/Users/chenyannan/dev/nodereps"
    prefix = "/Users/chenyannan/dev/nodereps"
    registry = "https://registry.npm.taobao.org/"

2、安裝腳手架

# 0.卸載腳手架
	npm uninstall -g @vue/cli  //卸載3.x版本腳手架
	npm uninstall -g vue-cli  //卸載2.x版本腳手架

# 1.Vue Cli官方網站
	https://cli.vuejs.org/zh/guide/

# 2.安裝vue Cli
	npm install -g vue-cli

3、第一個vue腳手架專案

Vue-cli目錄結構

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-2QDNftWz-1627871421740)(Vue實戰筆記(三).assets/image-20210721155403325.png)\

# 1.創建vue腳手架第一個專案
	vue init webpack 專案名
# 2.創建第一個專案
	hello     ------------->專案名
    -build  ------------->用來使用webpack打包使用build依賴  構建一些依賴檔案
    -config ------------->用來做整個專案配置目錄   主要用來對 開發 測驗 環境進行配置
    -node_modules  ------>用來管理專案中使用依賴
    -src					 ------>用來書寫vue的源代碼[重點]
    	+assets      ------>用來存放靜態資源 [重點]
      	components   ------>用來書寫Vue組件 [重點]
      	router			 ------>用來配置專案中路由[重點]
      	App.vue      ------>專案中根組件[重點]
      	main.js      ------>專案中主入口[重點]
    -static        ------>其它靜態
    -.babelrc      ------> 將es6語法轉為es5運行
    -.editorconfig ------> 專案編輯配置
    -.gitignore    ------> git版本控制忽略檔案
    -.postcssrc.js ------> 原始碼相關js
    -index.html    ------> 專案主頁
    -package.json  ------> 類似與pom.xml 依賴管理  jquery 不建議手動修改
    -package-lock.json ---->package.json加鎖
    -README.md         ----> 專案說明檔案

# 3.如何運行在專案的根目錄中執行
	npm run dev 運行前端系統

# 4.如何訪問專案
	http://localhost:8080    

# 5.Vue Cli中專案開發方式
	 注意: 一切皆組件   一個組件中   js代碼  html代碼  css樣式
	 	1. VueCli開發方式是在專案中開發一個一個組件對應一個業務功能模塊,日后可以將多個組件組合到一起形成一個前端系統
	 	2. 日后在使用vue Cli進行開發時不再書寫html,撰寫的是一個個組件(組件后綴.vue結尾的檔案),日后打包時vue cli會將組件編譯成運行的html檔案	  

rc 目錄

src目錄是專案的原始碼目錄,所有代碼都會寫在這里!

main.js

專案的入口檔案,我們知道所有的程式都會有一個入口

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'   // 引入VUE核心庫
import App from './App' // 引入一個當前目錄下的名字為App.vue的組件
import router from './router'

Vue.config.productionTip = false  // 是否要在生產環境當中給予提示功能,

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

  • import Vue from 'vue':ES6 寫法,會被轉換成 require(“vue”); (require 是 NodeJS 提供的模塊加載器)其實就相當于

    <script src = "vue"></script>

  • import App from './App' :意思同上,但是指定了查找路徑,./ 為當前目錄

  • Vue.config.productionTip = false:關閉瀏覽器控制臺關于環境的相關提示

  • new Vue({}):實體化 Vue

    • el: '#app':查找 index.html 中 id 為 app 的元素
    • template: '<App/>':模板,會將 index.html 中替換為
    • components: { App } :引入組件,使用的是 import App from ‘./App’ 定義的 App 組件;

App.vue

<template>
  <div id="app">
    <img src="./assets/logo.png">
	<h1>自定義腳手架</h1>
	<!--展示路由-->
    <router-view/>
  </div>
</template>

<script>
export default {
  name: 'App'
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
  • template:HTML 代碼模板,會替換 < App /> 中的內容

  • export default{…}:匯出 NodeJS 物件,作用是可以通過 import 關鍵字匯入

    • name: ‘App’:定義組件的名稱
    • components: { HelloWorld }:定義子組件
  • 在hello,Vue中,關于 < style scoped> 的說明:CSS 樣式僅在當前組件有效,宣告了樣式的作用域,是當前的界面私有的! 不加代表全域有效,

index.js 配置路由

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

Vue.use(Router) //注冊路由 new Vue({router,})

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    }
  ]
})

HelloWorld.vue

<!-- 一個組件代表一個業務功能:html標簽 js代碼 css代碼 -->
<template>
  <div class="hello">
    
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: '歡迎Vue'
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

4、如何開發Vue腳手架

注意:在Vue cli 中一切皆組件

1、我們在HelloWorld.vue的同級目錄下新建兩個Student和User組件,

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-liUgTnMu-1627871421742)(Vue實戰筆記(三).assets/image-20210721204921996.png)]


2、Student.vueUser.vue組件

Student.vue組件

<template>
  <div class="hello">
     <h1>hello world {{msg}} </h1>
	 <h3>我是學生管理的主頁</h3>
  </div>
</template>

<script>
export default {
  name: 'Student',
  data () {
    return {
      msg: '學生管理'
    }
  }
}
</script>

User.vue組件

<template>
  <div class="hello">
     <h1>hello world {{msg}} </h1>
	 <h3>我是用戶管理的主頁</h3>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: '用戶管理'
    }
  }
}
</script>

3、在App.vue組件中引入這兩個組件的鏈接,進行路由切換

<template>
  <div id="app">
    <img src="./assets/logo.png">
	<h1>自定義腳手架</h1>
	
	<router-link to="/">主頁</router-link>
	<router-link to="/user">用戶管理</router-link>
	<router-link to="/student">學生管理</router-link>
	
	<!--展示路由-->
    <router-view/>
  </div>
</template>

4、啟動專案,測驗一下

17、在腳手架中使用axios

17.1、安裝axios

# 1.安裝axios
	npm install axios --save

# 2.配置main.js中引入axios
	import axios from 'axios';
	Vue.prototype.$http=axios;

# 3.使用axios
	在需要發送異步請求的位置:this.$http.get("url").then((res)=>{}) this.$http.post("url").then((res)=>{})

18、Vue Cli腳手架專案部署

# 1.在專案根目錄中執行如下命令:
	npm run build
	注意:vue腳手架打包的專案必須在服務器上運行不能直接雙擊運行

# 2.打包之后當前專案中變化
	在打包之后專案中出現dist目錄,dist目錄就是vue腳手架專案生產目錄或者說是直接部署目錄

19、webstorm開發vue cli專案

19.1、簡介

WebStorm 是JetBrains公司旗下一款JavaScript 開發工具,已經被廣大中國JS開發者譽為“Web前端開發神器”、“最強大的HTML5編輯器”、“最智能的JavaScript IDE”等,與IntelliJ IDEA同源,繼承了IntelliJ IDEA強大的JS部分的功能,
在這里插入圖片描述

19.2、安裝

官網地址:http://www.jetbrains.com/webstorm/

選擇好安裝路徑

19.3、使用webstorm

webstorm和idea同屬于一家開發公司,因此使用方式基本一樣,

使用webstorm初始化專案

1、我們新建一個webstromcodes專案,

2、打開Terminal終端,輸入vue init webpack vue_day5 ,進行vue-day5專案的創建,

3、接下來的步驟和使用Vue Cli腳手架開發一樣,

4、顯示如下頁面,專案初始化成功,

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-aCUzAuOB-1627871421744)(Vue實戰筆記(三).assets/image-20210722212053257.png)]

可以看下目錄結構,和使用Vue CLI腳手架開發目錄結構一致,

5、在Terminal終端輸入cd vue_day5,進入當前專案根目錄,專案目錄中包含package.json才是根目錄,可以輸入dir查看當前目錄結構,

6、最后我們輸入npm run dev啟動專案,出現如下界面:

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-83zniwev-1627871421745)(Vue實戰筆記(三).assets/image-20210722212849013.png)]

說明專案成功運行!!!輸入http://localhost:8080 ,打開瀏覽器查看一下,出現默認界面,

main.js 專案中主入口

//引入vue.js
import Vue from 'vue'
//引入app.vue 組件
import App from './App'
//引入router目錄中 /index.js
import router from './router'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app', //指定vue實體作用范圍
  router,
  components: { App },
  template: '<App/>'
})

19.4、開發vue cli專案(一)

1、Student組件

template>
  <div class="hello">
    <h1>{{ msg }}</h1>

  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: '歡迎進入我的系統!!!'
    }
  }
}

2、User組件

<template>
  <div>
    <h1>用戶管理</h1>
    <table border="1" width="100%">
      <tr>
        <th>編號</th>
        <th>姓名</th>
        <th>年齡</th>
        <th>工資</th>
        <th>操作</th>
      </tr>
      <tr v-for="(user,index) in users" :key="user.id" >
        <td>{{user.id}}</td>
        <td>{{user.name}}</td>
        <td>{{user.age }}</td>
        <td>{{user.des}}</td>
        <td><a href="">洗掉</a> <a href="">修改</a></td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "User",
  data(){
    return {
      users:[],//定義陣列
    };
  },
  methods:{

  },
  computed:{

  },
  created() { //初始化階段發送請求查詢所有用戶資訊
    this.$http.get("http://localhost:8990/users").then(res=>{
       console.log(res.data);
       this.users = res.data;
    });
  }
}

3、App組件

<!--組件html標簽--><template>  <div id="app">    <!--展示vue腳手架logo-->    <img src="./assets/1.jpg" class="aa">    <br>    <!--主頁-->    <router-link to="/">主頁</router-link>    <!--用戶管理-->    <router-link to="/user">用戶管理</router-link>    <!--學生管理-->    <router-link to="/student">學生管理</router-link>    <!--展示路由組件-->    <router-view/>  </div></template><!--組件中js代碼--><script>export default {  name: 'App'}</script>

4、index.js

import Vue from 'vue'
import Router from 'vue-router'
//@ 代表src目錄
import HelloWorld from '@/components/HelloWorld'
import User from '@/components/User'
import Student from "../components/Student";
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/user',
      name: 'user',
      component: User
    },{
      path: '/student',
      name: 'student',
      component: Student
    }
  ]
})

啟動專案測驗一下:

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-ylfeDATy-1627871421747)(Vue實戰筆記(三).assets/image-20210724091247957.png)]

成功查詢到資料!!!

19.5、開發vue cli專案(二)

20、VueX 狀態管理

20.1、簡介&安裝

# 1.簡介
- Vuex 是一個專為 Vue.js 應用程式開發的狀態管理模式,它采用集中式存盤管理應用的所有組件的狀態,并以相應的規則保證狀態以一種可預測的方式發生變化

# 2.安裝vuex
-	npm install vuex --save

# 3.創建vue cli中創建store檔案夾

# 4.在stroe中創建index.js檔案
import Vue from 'vue'
import Vuex from 'vuex'
//1.安裝vuex
Vue.use(Vuex);
//2.創建store物件
const store = new Vuex.Store({
  
});
//3.暴露store物件
export default store;
# 5.在main.js中引入stroe并注冊到vue實體
import Vue from 'vue'
import App from './App'
import router from './router'
import store from "./stroe";//引入store
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
  store,//注冊狀態
})

20.2、state屬性

# 1.state屬性
- 作用: 用來全域定義一些共享的資料狀態

# 2.語法
    const store = new Vuex.Store({
    	state:{
    		counter:0,//定義共享狀態
    	},
    }

# 3.使用
	 {{$store.state.counter}} ===> {{this.$store.state.counter}}

20.3、mutations 屬性

# 1.mutations 屬性
- 作用: 用來定義對共享的資料修改的一系列函式

# 2.語法
    const store = new Vuex.Store({
      state:{
        counter:0,//定義共享狀態
      },
      mutations:{
        //增加
        increment(state){
          state.counter++
        },
        //減小
        decrement(state){
          state.counter--
        }
      }
    });

# 3.使用
	this.$store.commit('decrement');
	this.$store.commit('increment');

# 4.mutations傳遞引數

- a.定義帶有引數的函式
			mutations:{
     		//addCount 引數1:state 物件 引數2:自定義引數
     		addCount(state,counter){
        	console.log(counter);
        	return  state.counter += counter ;
      	}
    	}
- b.呼叫時傳遞引數
		this.$store.commit('addCount',11);

20.4、getters 屬性

# 1.getters 屬性
- 官方:  允許我們在 store 中定義“getter”(可以認為是 store 的計算屬性),就像計算屬性一樣,getter 的回傳值會根據	
	它的依賴被快取起來,且只有當它的依賴值發生了改變才會被重新計算,
- 作用: 用來定義對共享的資料的計算相關的一系列函式 相當于 computed 屬性 會對結果進行快取

# 2.語法
	  getters:{
      //平方
      mathSqrts(state){
        console.log("--------");
        return state.counter*state.counter;
      },
      //乘以一個數字
      mathSqrtsNumber(state,getters){
        return getters.mathSqrts*3;
      },
      //傳遞引數
      mathSqrtsNumbers(state,getters){
        return function (number){
          return  number;
        }
      }
    }

# 3.使用
-		1.{{$store.getters.mathSqrts}}
-   2.{{$store.getters.mathSqrtsNumber}}
-   3.{{$store.getters.mathSqrtsNumbers(3)}}

20.5、練習

index.js

import Vue from 'vue' //vue.js
import Vuex from 'vuex'  //vuex.js

//1. vue中使用vuex
Vue.use(Vuex);

//2. 創建store物件
export default new Vuex.Store({
    //state: 用來定義所有組件共享的資料
    state:{
      counter:0,
    },
    //mutations: 用來定義對共享資料的修改方法
    mutations:{
      incrCounter(state){
        state.counter++;
      },
      decrCounter(state){
        state.counter--;
      },
      incrCounterCount(state,count){
        state.counter += count;
      },
    },
   //getters: 相當于store共享資料計算屬性,該計算屬性中方法只會執行一次,只有計算屬性值發生變化才會重新計算,相當于之前的computed屬性
   getters:{
      incrCount(state){  //二次渲染計算
          return state.counter + 10;
      },
      match(state,getters){
          return getters.incrCount * 2;
      }
   }
});


User.vue

<template>
  <div>
    <h1>用戶管理--{{this.$store.state.counter}}--{{this.$store.getters.incrCount}}--{{this.$store.getters.match}}</h1>
    <input type="button" value="點我修改共享資料counter++" @click="changeStoreCounter">
    <input type="button" value="點我修改共享資料counter--" @click="decrStoreCounter">
    <input type="button" value="點我修改共享資料counter+5" @click="changeStoreCounterFive">
    <router-link to="/user/add" style="float: left">添加用戶資訊</router-link>
    <table border="1" width="100%">
      <tr>
        <th>編號</th>
        <th>姓名</th>
        <th>年齡</th>
        <th>工資</th>
        <th>操作</th>
      </tr>
      <tr v-for="(user,index) in users" :key="user.id" >
        <td>{{user.id}}</td>
        <td>{{user.name}}</td>
        <td>{{user.age }}</td>
        <td>{{user.des}}</td>
        <td><a href="javascript:;" @click="delUser(user.id)">洗掉</a> <router-link to="/user/add?id=user.id&name" >修改</router-link></td>
      </tr>
    </table>

    <hr>
    <!--顯示子組件路由-->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "User",
  data(){
    return {
      users:[],//定義陣列
    };
  },
  methods:{
    findAll(){
      this.$http.get("http://localhost:8990/users").then(res=>{
        console.log(res.data);
        this.users = res.data;
      });
    },
    delUser(id){
      //友情提醒洗掉
      if(window.confirm("您確定要洗掉這條記錄嗎?")){
        this.$http.delete("http://localhost:8990/delete/"+id).then(res=>{
          alert("用戶資訊洗掉成功!");
          this.findAll(); 呼叫查詢所有
        }).catch(err=>{
          alert("用戶資訊洗掉失敗!");
        });
      }
    },
    changeStoreCounter(){
       //修改共享資料counter++
      this.$store.commit('incrCounter');
    },
    decrStoreCounter(){
      //修改共享資料counter--
      this.$store.commit('decrCounter');
    },
    changeStoreCounterFive(){
      //修改共享資料counter+5
      this.$store.commit('incrCounterCount',5);
    }
  },
  computed:{

  },
  created() { //初始化階段發送請求查詢所有用戶資訊
    this.findAll();
  },  //user  /user/add /user/edit
  beforeRouteUpdate(to,from,next){ //當前組件中路由更新時自動觸發的函式
    this.findAll();
    next(); //放行后路由后續操作
  },

}
</script>

<style scoped>
  th{
    background-color: beige;
  }
</style>

在這里插入圖片描述

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/291919.html

標籤:其他

上一篇:小白入門之前端網頁技術 Vue

下一篇:Nacos.04.集群搭建及高可用方案

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 面試突擊第一季,第二季,第三季

    第一季必考 https://www.bilibili.com/video/BV1FE411y79Y?from=search&seid=15921726601957489746 第二季分布式 https://www.bilibili.com/video/BV13f4y127ee/?spm_id_fro ......

    uj5u.com 2020-09-10 05:35:24 more
  • 第三單元作業總結

    1.前言 這應該是本學期最后一次寫作業總結了吧。總體來說,對作業的節奏也差不多掌握了,作業做起來的效率也更高了。雖然和之前的作業一樣,作業中都要用到新的知識,但是相比之前,更加懂得了如何利用工具以及資料。雖然之間卡過殼,但總體而言,這幾次作業還算完成的比較好。 2.作業程序總結 相比前兩個單元,此單 ......

    uj5u.com 2020-09-10 05:35:41 more
  • 北航OO(2020)第四單元博客作業暨課程總結博客

    北航OO(2020)第四單元博客作業暨課程總結博客 本單元作業的架構設計 在本單元中,由于UML圖具有比較清晰的樹形結構,因此我對其中需要進行查詢操作的元素進行了包裝,在樹的父節點中存盤所有孩子的參考。考慮到性能問題,我采用了快取機制,一次查詢后盡可能快取已經遍歷過的資訊,以減少遍歷次數。 本單元我 ......

    uj5u.com 2020-09-10 05:35:48 more
  • BUAA_OO_第四單元

    一、UML決議器設計 ? 先看下題目:第四單元實作一個基于JDK 8帶有效性檢查的UML(Unified Modeling Language)類圖,順序圖,狀態圖分析器 MyUmlInteraction,實際上我們要建立一個有向圖模型,UML中的物件(元素)可能與同級元素連接,也可與低級元素相連形成 ......

    uj5u.com 2020-09-10 05:35:54 more
  • 6.1邏輯運算子

    邏輯運算子 1. && 短路與 運算式1 && 運算式2 01.運算式1為true并且運算式2也為true 整體回傳為true 02.運算式1為false,將不會執行運算式2 整體回傳為false 03.只要有一個運算式為false 整體回傳為false 2. || 短路或 運算式1 || 運算式2 ......

    uj5u.com 2020-09-10 05:35:56 more
  • BUAAOO 第四單元 & 課程總結

    1. 第四單元:StarUml檔案決議 本單元采用了圖模型決議UML。 UML檔案可以抽象為圖、子圖、邊的邏輯結構。 在實作中,圖的節點包括類、介面、屬性,子圖包括狀態圖、順序圖等。 采用了三次遍歷UML元素的方法建圖,第一遍遍歷建點,第二、三次遍歷設定屬性、連邊,實作圖物件的初始化。這里借鑒了一些 ......

    uj5u.com 2020-09-10 05:36:06 more
  • 談談我對C# 多型的理解

    面向物件三要素:封裝、繼承、多型。 封裝和繼承,這兩個比較好理解,但要理解多型的話,可就稍微有點難度了。今天,我們就來講講多型的理解。 我們應該經常會看到面試題目:請談談對多型的理解。 其實呢,多型非常簡單,就一句話:呼叫同一種方法產生了不同的結果。 具體實作方式有三種。 一、多載 多載很簡單。 p ......

    uj5u.com 2020-09-10 05:36:09 more
  • Python 資料驅動工具:DDT

    背景 python 的unittest 沒有自帶資料驅動功能。 所以如果使用unittest,同時又想使用資料驅動,那么就可以使用DDT來完成。 DDT是 “Data-Driven Tests”的縮寫。 資料:http://ddt.readthedocs.io/en/latest/ 使用方法 dd. ......

    uj5u.com 2020-09-10 05:36:13 more
  • Python里面的xlrd模塊詳解

    那我就一下面積個問題對xlrd模塊進行學習一下: 1.什么是xlrd模塊? 2.為什么使用xlrd模塊? 3.怎樣使用xlrd模塊? 1.什么是xlrd模塊? ?python操作excel主要用到xlrd和xlwt這兩個庫,即xlrd是讀excel,xlwt是寫excel的庫。 今天就先來說一下xl ......

    uj5u.com 2020-09-10 05:36:28 more
  • 當我們創建HashMap時,底層到底做了什么?

    jdk1.7中的底層實作程序(底層基于陣列+鏈表) 在我們new HashMap()時,底層創建了默認長度為16的一維陣列Entry[ ] table。當我們呼叫map.put(key1,value1)方法向HashMap里添加資料的時候: 首先,呼叫key1所在類的hashCode()計算key1 ......

    uj5u.com 2020-09-10 05:36:38 more
最新发布
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:20:47 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:20:25 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:20:17 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:20:10 more
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:19:44 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:19:07 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:18:57 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:18:49 more
  • 05單件模式

    #經典的單件模式 public class Singleton { private static Singleton uniqueInstance; //一個靜態變數持有Singleton類的唯一實體。 // 其他有用的實體變數寫在這里 //構造器宣告為私有,只有Singleton可以實體化這個類! ......

    uj5u.com 2023-04-19 08:42:51 more
  • 【架構與設計】常見微服務分層架構的區別和落地實踐

    軟體工程的方方面面都遵循一個最基本的道理:沒有銀彈,架構分層模型更是如此,每一種都有各自優缺點,所以請根據不同的業務場景,并遵循簡單、可演進這兩個重要的架構原則選擇合適的架構分層模型即可。 ......

    uj5u.com 2023-04-19 08:42:41 more