第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

請(qǐng)教各位前輩,vue-cli可以跨域拿到豆瓣的數(shù)據(jù),為什么不能跨域拿到本地?cái)?shù)據(jù)庫的數(shù)據(jù)呢?

請(qǐng)教各位前輩,vue-cli可以跨域拿到豆瓣的數(shù)據(jù),為什么不能跨域拿到本地?cái)?shù)據(jù)庫的數(shù)據(jù)呢?

慕工程0101907 2019-05-21 11:11:38
嘗試用vue-cli來獲取本地服務(wù)器數(shù)據(jù)庫的數(shù)據(jù)但返回以下錯(cuò)誤提示,用同樣的寫法卻可以獲取豆瓣的數(shù)據(jù)。折騰來一個(gè)晚上無法解決,希望前輩們能抽空指點(diǎn)!不勝感激![HPM]Erroroccurredwhiletryingtoproxyrequestfromlocalhost:8080tohttp://localhost:3000(ECONNREFUSED)(https://nodejs.org/api/errors.html#errors_common_system_errors)我的代碼部分config->index.jsproxyTable:{'/api':{target:'http://localhost:3000',changeOrigin:true,pathRewrite:{'^/api':''}}src->main.jsimportVuefrom'vue'importAppfrom'./App'importVueRouterfrom'vue-router'importrouterConfigfrom'./router.config.js'//引入路由importAxiosfrom'axios'Vue.config.productionTip=false;Vue.prototype.$axios=Axios;Vue.prototype.HOST='/api';Vue.use(VueRouter);constrouter=newVueRouter(routerConfig)//啟動(dòng)路由/*eslint-disableno-new*/newVue({el:'#app',router,//掛載路由components:{App},//組件名template:'',})src->App.vueexportdefault{created(){varurl=this.HOSTthis.$axios.get(url,{}).then((res)=>{console.log(res.data)},(res)=>{alert(res.status)})}}后臺(tái)serverconstexpress=require('express');constmysql=require('mysql');constdb=mysql.createPool({localhost:'localhost',user:'root',password:'123456',database:'blog'})constserver=express();server.use('/api',(req,res)=>{db.query(`SELECT*FROMarticles_table`,(err,data)=>{if(err){console.error(err);res.status(500).send('databaseerror').end();}else{res.send(data)}})})server.listen(3000)
查看完整描述

2 回答

?
qq_笑_17

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊

感謝各位前輩關(guān)注和解答,最后我用了以下辦法來解決
1、安裝
npminstall--save-devconcurrently
2、將package.json的script加上
"server":"nodeserver.js",
"go":"concurrently--kill-others\"npmrundev\"\"npmrunserver\""
3、輸入命令
npmrungo
然后就可以了
                            
查看完整回答
反對(duì) 回復(fù) 2019-05-21
  • 2 回答
  • 0 關(guān)注
  • 583 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)