vue douban
1.0.0
基於vue2, vue-router, vuex, axios及豆瓣API 和Element UI 框架的項目
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --reportFor detailed explanation on how things work, checkout the guide and docs for vue-loader.
├── App . vue
├── api
│ ├── base . js
│ └── movie . js
├── assets
│ └── logo . png
├── components
├── main . js
├── router
│ └── index . js
├── store
│ ├── index . js
│ └── movies
│ ├── module . js
│ └── type . js
└── views
├── Home . vue
├── NavMenu . vue
└── movie
├── MovieDetail . vue
└── MovieList . vue 電影API:
/v2/movie/search?q={text}電影搜尋api;(暫未實作)/v2/movie/in_theaters ;/v2/movie/coming_soon ;/v2/movie/subject/:id單一電影條目資訊。更多關於豆瓣的api可以前往豆瓣api官網查看。
豆瓣API 跨域配置: 在/config/index.js中設定代理程式:
dev: {
env : require ( './dev.env' ) ,
port : 8880 ,
assetsSubDirectory : 'static' ,
assetsPublicPath : '/' ,
proxyTable : {
'/api' : {
target : 'http://api.douban.com/v2' ,
changeOrigin : true ,
pathRewrite : {
'^/api' : ''
}
}
}
}在proxyTable這個屬性中,設定target屬性為我們要代理的目標位址。設定為http://api.douban.com/v2 ,這樣我們就可以在應用程式中呼叫/api/movie/in_theaters來存取http://api.douban.com/v2/movie/in_theaters ,從而解決跨域的問題。
關於vue-cli更多關於跨域的設定可以看官網文檔