vue+node+mysql學習筆記

來源:互聯網
上載者:User

標籤:nal   tar   null   mysql學習   targe   middle   moment   管理員   base   

1.建立資料庫

create database vueBlog;use vueBlog;/*建立管理員表,用於後台登入,欄位為管理員編號(自增長)、帳號、密碼、登入時間*/create table if not exists admin(    id int auto_increment primary key,    name varchar(20) not null,     password varchar(50) not null,    loginTime varchar(50) not null);

 

2.建立項目目錄結構

  1)使用vue-cli初始化項目  

# 全域安裝 vue-cli$ npm install --global vue-cli# 建立一個基於 webpack 模板的新項目$ vue init webpack vue-blog# 安裝依賴,走你$ cd vue-blog$ cnpm install$ npm run dev

 2)建立admin目錄,存放後台相關檔案

  • config 存放預設檔案
  • lib 存放操作資料庫檔案
  • middlewares 存放判斷登入與否檔案
  • public 存放樣式檔案
  • routes 存放路由檔案
  • views 存放模板檔案
  • index 程式主檔案

  3)安裝後台所需模組

  安裝之前我們使用cnpm安裝

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm i koa koa-bodyparser koa-mysql-session koa-router koa-session-minimal koa-static koa-views md5 moment mysql ejs --save

各模組用處

koa node架構koa-bodyparser 表單解析中介軟體koa-mysql-session、koa-session-minimal 處理資料庫的中介軟體koa-router 路由中介軟體koa-static 靜態資源載入中介軟體ejs 模板引擎md5 密碼加密moment 時間中介軟體mysql 資料庫koa-views 模板呈現中介軟體

 

vue+node+mysql學習筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.