1、vue頁面是一張表格,表格數(shù)據(jù)從數(shù)據(jù)庫讀取,現(xiàn)在讀不到數(shù)據(jù)。
2、數(shù)據(jù)庫連接成功:
但是界面報錯如下:
3、鏈接數(shù)據(jù)庫代碼結(jié)構(gòu)和代碼:
db.js
// 數(shù)據(jù)庫連接配置
module.exports = {
mysql: {
host: '123.139.88.227',
user: 'campus',
password: 'root',
database: '***',
port: '33061'
}
}
index.js
const userApi = require('./api/newStuApi');
const fs = require('fs');
const path = require('path');
const bodyParser = require('body-parser');
const express = require('express');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
// 后端api路由
app.use('/api/newStu', userApi);
// 監(jiān)聽端口
app.listen(3306);
console.log('success listen at port:3306......');
sqlMap.js
/**
* Created by Administrator on 2017-11-15.
*/
// sql語句
var sqlMap = {
// 用戶
newStu: {
search: 'select NAME,YEAR,ENROLL_TYPE,MAJOR_CODE,EXAM_NUMBER,MOBILE_PHONE,TELEPHONE,ADDRESS FROM EM_NEW_STUDENT '
}
}
module.exports = sqlMap;
測試代碼,在界面點擊“查詢”`
getList() {
this.listLoading = true;
var NAME = this.NAME;
var YEAR = this.YEAR;
var ENROLL_TYPE = this.ENROLL_TYPE;
var MAJOR_CODE = this.MAJOR_CODE;
var EXAM_NUMBER = this.EXAM_NUMBER;
var MOBILE_PHONE = this.MOBILE_PHONE;
var TELEPHONE = this.TELEPHONE;
var ADDRESS = this.ADDRESS;
this.$http.get('/api/newStu/searchNewStu', data => {
this.$set('NAME', data.NAME);
this.$set('YEAR', data.YEAR);
this.$set('ENROLL_TYPE', data.ENROLL_TYPE);
this.$set('MAJOR_CODE', data.MAJOR_CODE);
this.$set('EXAM_NUMBER', data.EXAM_NUMBER);
this.$set('MOBILE_PHONE', data.MOBILE_PHONE);
this.$set('TELEPHONE', data.TELEPHONE);
this.$set('ADDRESS', data.ADDRESS);
}).then((response) => {
console.log(response);
})
/* fetchList(this.listQuery).then(response => {
this.list = response.data.items
this.total = response.data.total
this.listLoading = false
})*/
},
/* 查詢*/
handleSearch() {
this.listQuery.page = 1
this.getList()
},
我認為有問題的地方:
mysql db.js配置中host不需要http://
你配置的路由中只有一個/api/newStu 而沒有/api/newStu/search
啟動的時候是用 node index.js 而不是 node index
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團,成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負責(zé)iOS教學(xué)及管理工作。
浪潮集團項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。